Eliminate in-out parameter for gossip shutdown function (#30986)

This commit is contained in:
Brennan 2023-03-30 09:25:25 -07:00 committed by GitHub
parent 5ae3288a0b
commit 7804d9aa92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -369,14 +369,11 @@ pub fn fail_rpc_node(
blacklisted_rpc_nodes.insert(*rpc_id); blacklisted_rpc_nodes.insert(*rpc_id);
} }
fn shutdown_gossip_service( fn shutdown_gossip_service(gossip: (Arc<ClusterInfo>, Arc<AtomicBool>, GossipService)) {
gossip: &mut Option<(Arc<ClusterInfo>, Arc<AtomicBool>, GossipService)>, let (cluster_info, gossip_exit_flag, gossip_service) = gossip;
) { cluster_info.save_contact_info();
if let Some((cluster_info, gossip_exit_flag, gossip_service)) = gossip.take() { gossip_exit_flag.store(true, Ordering::Relaxed);
cluster_info.save_contact_info(); gossip_service.join().unwrap();
gossip_exit_flag.store(true, Ordering::Relaxed);
gossip_service.join().unwrap();
}
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
@ -431,7 +428,9 @@ pub fn attempt_download_genesis_and_snapshot(
} }
} }
shutdown_gossip_service(gossip); if let Some(gossip) = gossip.take() {
shutdown_gossip_service(gossip);
}
let rpc_client_slot = rpc_client let rpc_client_slot = rpc_client
.get_slot_with_commitment(CommitmentConfig::finalized()) .get_slot_with_commitment(CommitmentConfig::finalized())
@ -658,7 +657,9 @@ pub fn rpc_bootstrap(
} }
} }
shutdown_gossip_service(&mut gossip); if let Some(gossip) = gossip.take() {
shutdown_gossip_service(gossip);
}
} }
/// Get RPC peer node candidates to download from. /// Get RPC peer node candidates to download from.