Add option to monitor catchup at max commitment
This commit is contained in:
parent
303a1207c1
commit
c5b2db72a2
|
@ -173,6 +173,7 @@ pub enum CliCommand {
|
||||||
Catchup {
|
Catchup {
|
||||||
node_pubkey: Pubkey,
|
node_pubkey: Pubkey,
|
||||||
node_json_rpc_url: Option<String>,
|
node_json_rpc_url: Option<String>,
|
||||||
|
commitment_config: CommitmentConfig,
|
||||||
follow: bool,
|
follow: bool,
|
||||||
},
|
},
|
||||||
ClusterVersion,
|
ClusterVersion,
|
||||||
|
@ -1594,8 +1595,15 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
CliCommand::Catchup {
|
CliCommand::Catchup {
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
node_json_rpc_url,
|
node_json_rpc_url,
|
||||||
|
commitment_config,
|
||||||
follow,
|
follow,
|
||||||
} => process_catchup(&rpc_client, node_pubkey, node_json_rpc_url, *follow),
|
} => process_catchup(
|
||||||
|
&rpc_client,
|
||||||
|
node_pubkey,
|
||||||
|
node_json_rpc_url,
|
||||||
|
*commitment_config,
|
||||||
|
*follow,
|
||||||
|
),
|
||||||
CliCommand::ClusterVersion => process_cluster_version(&rpc_client),
|
CliCommand::ClusterVersion => process_cluster_version(&rpc_client),
|
||||||
CliCommand::CreateAddressWithSeed {
|
CliCommand::CreateAddressWithSeed {
|
||||||
from_pubkey,
|
from_pubkey,
|
||||||
|
|
|
@ -68,6 +68,14 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
||||||
.validator(is_url)
|
.validator(is_url)
|
||||||
.help("JSON RPC URL for validator, which is useful for validators with a private RPC service")
|
.help("JSON RPC URL for validator, which is useful for validators with a private RPC service")
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("confirmed")
|
||||||
|
.long("confirmed")
|
||||||
|
.takes_value(false)
|
||||||
|
.help(
|
||||||
|
"Return information at maximum-lockout commitment level",
|
||||||
|
),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("follow")
|
Arg::with_name("follow")
|
||||||
.long("follow")
|
.long("follow")
|
||||||
|
@ -275,11 +283,17 @@ pub fn parse_catchup(
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?.unwrap();
|
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?.unwrap();
|
||||||
let node_json_rpc_url = value_t!(matches, "node_json_rpc_url", String).ok();
|
let node_json_rpc_url = value_t!(matches, "node_json_rpc_url", String).ok();
|
||||||
|
let commitment_config = if matches.is_present("confirmed") {
|
||||||
|
CommitmentConfig::default()
|
||||||
|
} else {
|
||||||
|
CommitmentConfig::recent()
|
||||||
|
};
|
||||||
let follow = matches.is_present("follow");
|
let follow = matches.is_present("follow");
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Catchup {
|
command: CliCommand::Catchup {
|
||||||
node_pubkey,
|
node_pubkey,
|
||||||
node_json_rpc_url,
|
node_json_rpc_url,
|
||||||
|
commitment_config,
|
||||||
follow,
|
follow,
|
||||||
},
|
},
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -436,6 +450,7 @@ pub fn process_catchup(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
node_pubkey: &Pubkey,
|
node_pubkey: &Pubkey,
|
||||||
node_json_rpc_url: &Option<String>,
|
node_json_rpc_url: &Option<String>,
|
||||||
|
commitment_config: CommitmentConfig,
|
||||||
follow: bool,
|
follow: bool,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let sleep_interval = 5;
|
let sleep_interval = 5;
|
||||||
|
@ -484,8 +499,8 @@ pub fn process_catchup(
|
||||||
let mut previous_rpc_slot = std::u64::MAX;
|
let mut previous_rpc_slot = std::u64::MAX;
|
||||||
let mut previous_slot_distance = 0;
|
let mut previous_slot_distance = 0;
|
||||||
loop {
|
loop {
|
||||||
let rpc_slot = rpc_client.get_slot_with_commitment(CommitmentConfig::recent())?;
|
let rpc_slot = rpc_client.get_slot_with_commitment(commitment_config)?;
|
||||||
let node_slot = node_client.get_slot_with_commitment(CommitmentConfig::recent())?;
|
let node_slot = node_client.get_slot_with_commitment(commitment_config)?;
|
||||||
if !follow && node_slot > std::cmp::min(previous_rpc_slot, rpc_slot) {
|
if !follow && node_slot > std::cmp::min(previous_rpc_slot, rpc_slot) {
|
||||||
progress_bar.finish_and_clear();
|
progress_bar.finish_and_clear();
|
||||||
return Ok(format!(
|
return Ok(format!(
|
||||||
|
|
Loading…
Reference in New Issue