Skip to content

Commit

Permalink
Prevent bootnode adding its own ENR
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Jul 29, 2021
1 parent a3fb7b3 commit 0c25e92
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions boot_node/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
};

// construct the discv5 server
let mut discv5 = Discv5::new(config.local_enr, config.local_key, discv5_config).unwrap();
let mut discv5 =
Discv5::new(config.local_enr.clone(), config.local_key, discv5_config).unwrap();

// If there are any bootnodes add them to the routing table
for enr in config.boot_nodes {
info!(log, "Adding bootnode"; "address" => format!("{:?}", enr.udp_socket()), "peer_id" => enr.peer_id().to_string(), "node_id" => enr.node_id().to_string());
if let Err(e) = discv5.add_enr(enr) {
slog::warn!(log, "Failed adding ENR"; "error" => e.to_string());
info!(
log,
"Adding bootnode";
"address" => ?enr.udp_socket(),
"peer_id" => enr.peer_id().to_string(),
"node_id" => enr.node_id().to_string()
);
if enr != config.local_enr {
if let Err(e) = discv5.add_enr(enr) {
slog::warn!(log, "Failed adding ENR"; "error" => e.to_string());
}
}
}

Expand Down

0 comments on commit 0c25e92

Please sign in to comment.