diff --git a/beacon_node/eth2_libp2p/src/behaviour/mod.rs b/beacon_node/eth2_libp2p/src/behaviour/mod.rs index 5b45a77d5b..09d82e2e86 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/mod.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/mod.rs @@ -348,6 +348,8 @@ impl Behaviour { } /// Subscribes to a gossipsub topic. + /// + /// Returns `true` if the subscription was successful and `false` otherwise. pub fn subscribe(&mut self, topic: GossipTopic) -> bool { // update the network globals self.network_globals @@ -358,13 +360,13 @@ impl Behaviour { let topic: Topic = topic.into(); match self.gossipsub.subscribe(&topic) { - Err(_) => { - warn!(self.log, "Failed to subscribe to topic"; "topic" => %topic); + Err(e) => { + warn!(self.log, "Failed to subscribe to topic"; "topic" => %topic, "error" => ?e); false } - Ok(v) => { + Ok(_) => { debug!(self.log, "Subscribed to topic"; "topic" => %topic); - v + true } } } diff --git a/beacon_node/eth2_libp2p/src/discovery/mod.rs b/beacon_node/eth2_libp2p/src/discovery/mod.rs index a748894267..f2957c0ce3 100644 --- a/beacon_node/eth2_libp2p/src/discovery/mod.rs +++ b/beacon_node/eth2_libp2p/src/discovery/mod.rs @@ -444,15 +444,13 @@ impl Discovery { )); } + // The bitfield is already set to required value if current_bitfield .get(id) .map_err(|_| String::from("Subnet ID out of bounds"))? == value { - return Err(format!( - "Subnet id: {} already in the local ENR already has value: {}", - id, value - )); + return Ok(()); } // set the subnet bitfield in the ENR @@ -480,15 +478,13 @@ impl Discovery { )); } + // The bitfield is already set to required value if current_bitfield .get(id) .map_err(|_| String::from("Subnet ID out of bounds"))? == value { - return Err(format!( - "Subnet id: {} already in the local ENR already has value: {}", - id, value - )); + return Ok(()); } // set the subnet bitfield in the ENR