`catchup` now supports an optional RPC URL argument for validators with private RPC (#8629)
automerge
This commit is contained in:
parent
408d5da50f
commit
09a0325534
|
@ -167,6 +167,7 @@ pub enum CliCommand {
|
||||||
// Cluster Query Commands
|
// Cluster Query Commands
|
||||||
Catchup {
|
Catchup {
|
||||||
node_pubkey: Pubkey,
|
node_pubkey: Pubkey,
|
||||||
|
node_json_rpc_url: Option<String>,
|
||||||
},
|
},
|
||||||
ClusterVersion,
|
ClusterVersion,
|
||||||
CreateAddressWithSeed {
|
CreateAddressWithSeed {
|
||||||
|
@ -1550,7 +1551,10 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
CliCommand::Address => Ok(format!("{}", config.pubkey()?)),
|
CliCommand::Address => Ok(format!("{}", config.pubkey()?)),
|
||||||
|
|
||||||
// Return software version of solana-cli and cluster entrypoint node
|
// Return software version of solana-cli and cluster entrypoint node
|
||||||
CliCommand::Catchup { node_pubkey } => process_catchup(&rpc_client, node_pubkey),
|
CliCommand::Catchup {
|
||||||
|
node_pubkey,
|
||||||
|
node_json_rpc_url,
|
||||||
|
} => process_catchup(&rpc_client, node_pubkey, node_json_rpc_url),
|
||||||
CliCommand::ClusterVersion => process_cluster_version(&rpc_client),
|
CliCommand::ClusterVersion => process_cluster_version(&rpc_client),
|
||||||
CliCommand::CreateAddressWithSeed {
|
CliCommand::CreateAddressWithSeed {
|
||||||
from_pubkey,
|
from_pubkey,
|
||||||
|
|
|
@ -60,6 +60,14 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
||||||
.validator(is_pubkey_or_keypair)
|
.validator(is_pubkey_or_keypair)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Identity pubkey of the validator"),
|
.help("Identity pubkey of the validator"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("node_json_rpc_url")
|
||||||
|
.index(2)
|
||||||
|
.value_name("URL")
|
||||||
|
.takes_value(true)
|
||||||
|
.validator(is_url)
|
||||||
|
.help("JSON RPC URL for validator, which is useful for validators with a private RPC service")
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
|
@ -238,8 +246,12 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
||||||
|
|
||||||
pub fn parse_catchup(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_catchup(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let node_pubkey = pubkey_of(matches, "node_pubkey").unwrap();
|
let node_pubkey = pubkey_of(matches, "node_pubkey").unwrap();
|
||||||
|
let node_json_rpc_url = value_t!(matches, "node_json_rpc_url", String).ok();
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Catchup { node_pubkey },
|
command: CliCommand::Catchup {
|
||||||
|
node_pubkey,
|
||||||
|
node_json_rpc_url,
|
||||||
|
},
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -362,20 +374,29 @@ fn new_spinner_progress_bar() -> ProgressBar {
|
||||||
progress_bar
|
progress_bar
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_catchup(rpc_client: &RpcClient, node_pubkey: &Pubkey) -> ProcessResult {
|
pub fn process_catchup(
|
||||||
|
rpc_client: &RpcClient,
|
||||||
|
node_pubkey: &Pubkey,
|
||||||
|
node_json_rpc_url: &Option<String>,
|
||||||
|
) -> ProcessResult {
|
||||||
let cluster_nodes = rpc_client.get_cluster_nodes()?;
|
let cluster_nodes = rpc_client.get_cluster_nodes()?;
|
||||||
|
|
||||||
let rpc_addr = cluster_nodes
|
let node_client = if let Some(node_json_rpc_url) = node_json_rpc_url {
|
||||||
|
RpcClient::new(node_json_rpc_url.to_string())
|
||||||
|
} else {
|
||||||
|
RpcClient::new_socket(
|
||||||
|
cluster_nodes
|
||||||
.iter()
|
.iter()
|
||||||
.find(|contact_info| contact_info.pubkey == node_pubkey.to_string())
|
.find(|contact_info| contact_info.pubkey == node_pubkey.to_string())
|
||||||
.ok_or_else(|| format!("Contact information not found for {}", node_pubkey))?
|
.ok_or_else(|| format!("Contact information not found for {}", node_pubkey))?
|
||||||
.rpc
|
.rpc
|
||||||
.ok_or_else(|| format!("RPC service not found for {}", node_pubkey))?;
|
.ok_or_else(|| format!("RPC service not found for {}", node_pubkey))?,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let progress_bar = new_spinner_progress_bar();
|
let progress_bar = new_spinner_progress_bar();
|
||||||
progress_bar.set_message("Connecting...");
|
progress_bar.set_message("Connecting...");
|
||||||
|
|
||||||
let node_client = RpcClient::new_socket(rpc_addr);
|
|
||||||
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;
|
||||||
let sleep_interval = 5;
|
let sleep_interval = 5;
|
||||||
|
|
Loading…
Reference in New Issue