Avoid panic if no rpc peers exist
This commit is contained in:
parent
b44d8c394e
commit
feeaad619a
@ -549,10 +549,13 @@ impl Replicator {
|
||||
previous_blockhash: &Hash,
|
||||
) -> result::Result<(Hash, u64), Error> {
|
||||
for _ in 0..10 {
|
||||
let rpc_client = {
|
||||
let rpc_peers = {
|
||||
let cluster_info = cluster_info.read().unwrap();
|
||||
let rpc_peers = cluster_info.rpc_peers();
|
||||
cluster_info.rpc_peers()
|
||||
};
|
||||
debug!("rpc peers: {:?}", rpc_peers);
|
||||
if !rpc_peers.is_empty() {
|
||||
let rpc_client = {
|
||||
let node_index = thread_rng().gen_range(0, rpc_peers.len());
|
||||
RpcClient::new_socket(rpc_peers[node_index].rpc)
|
||||
};
|
||||
@ -592,6 +595,7 @@ impl Replicator {
|
||||
return Ok((storage_blockhash, storage_slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
info!("waiting for segment...");
|
||||
sleep(Duration::from_secs(5));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user