From db5251a524769adf3d8824e46ab587c99a4e968e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2020 20:42:51 +0000 Subject: [PATCH] `solana catchup` now retries if the initial RPC connection fails (#12645) (cherry picked from commit 978b26a9c593093205f48df1b96b98d90066dd9f) Co-authored-by: Michael Vines --- cli/src/cluster_query.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 2e033827d6..ad449f496d 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -15,6 +15,7 @@ use solana_cli_output::{ *, }; use solana_client::{ + client_error::ClientErrorKind, pubsub_client::PubsubClient, rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient}, rpc_config::{RpcLargestAccountsConfig, RpcLargestAccountsFilter}, @@ -537,7 +538,20 @@ pub fn process_catchup( RpcClient::new_socket(rpc_addr) }; - let reported_node_pubkey = node_client.get_identity()?; + let reported_node_pubkey = loop { + match node_client.get_identity() { + Ok(reported_node_pubkey) => break reported_node_pubkey, + Err(err) => { + if let ClientErrorKind::Reqwest(err) = err.kind() { + progress_bar.set_message(&format!("Connection failed: {}", err)); + sleep(Duration::from_secs(sleep_interval as u64)); + continue; + } + return Err(Box::new(err)); + } + } + }; + if reported_node_pubkey != *node_pubkey { return Err(format!( "The identity reported by node RPC URL does not match. Expected: {:?}. Reported: {:?}",