From 0c25e927fa755b2e5c986b894b7b84b4c4a0495f Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 26 Jul 2021 12:34:34 +1000 Subject: [PATCH] Prevent bootnode adding its own ENR --- boot_node/src/server.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/boot_node/src/server.rs b/boot_node/src/server.rs index ed563504b0b..3cdd8789a3e 100644 --- a/boot_node/src/server.rs +++ b/boot_node/src/server.rs @@ -40,13 +40,22 @@ pub async fn run(config: BootNodeConfig, 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()); + } } }