Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Validators now run a full gossip node while looking for a snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Mar 15, 2020
1 parent dd5e320 commit 5481d1a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ impl ClusterInfo {
.unwrap()
}

fn gossip_contact_info(id: &Pubkey, gossip: SocketAddr) -> ContactInfo {
pub fn gossip_contact_info(id: &Pubkey, gossip: SocketAddr) -> ContactInfo {
ContactInfo {
id: *id,
gossip,
Expand Down
28 changes: 18 additions & 10 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ fn get_trusted_snapshot_hashes(
}
}

fn start_gossip_spy(
fn start_gossip_node(
identity_keypair: &Arc<Keypair>,
entrypoint_gossip: &SocketAddr,
gossip_addr: &SocketAddr,
gossip_socket: UdpSocket,
) -> (Arc<RwLock<ClusterInfo>>, Arc<AtomicBool>, GossipService) {
let mut cluster_info = ClusterInfo::new(
ClusterInfo::spy_contact_info(&identity_keypair.pubkey()),
ClusterInfo::gossip_contact_info(&identity_keypair.pubkey(), *gossip_addr),
identity_keypair.clone(),
);
cluster_info.set_entrypoint(ContactInfo::new_gossip_entry_point(entrypoint_gossip));
Expand Down Expand Up @@ -859,13 +860,19 @@ pub fn main() {
});

let gossip_host = if let Some(entrypoint_addr) = entrypoint_addr {
solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
eprintln!(
"Failed to contact cluster entrypoint {}: {}",
entrypoint_addr, err
);
exit(1);
})
let ip_addr =
solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
eprintln!(
"Failed to contact cluster entrypoint {}: {}",
entrypoint_addr, err
);
exit(1);
});
info!(
"{} reports the IP address for this machine as {}",
entrypoint_addr, ip_addr
);
ip_addr
} else {
solana_net_utils::parse_host(matches.value_of("gossip_host").unwrap_or("127.0.0.1"))
.unwrap_or_else(|err| {
Expand Down Expand Up @@ -935,9 +942,10 @@ pub fn main() {
);

if !no_genesis_fetch {
let (cluster_info, gossip_exit_flag, gossip_service) = start_gossip_spy(
let (cluster_info, gossip_exit_flag, gossip_service) = start_gossip_node(
&identity_keypair,
&cluster_entrypoint.gossip,
&node.info.gossip,
node.sockets.gossip.try_clone().unwrap(),
);

Expand Down

0 comments on commit 5481d1a

Please sign in to comment.