diff --git a/src/error.rs b/src/error.rs index f1d34300..06defba1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,7 +18,7 @@ pub enum Error { /// The secret key does not match the provided ENR. InvalidSecretKey, /// An invalid signature was received for a challenge. - InvalidChallengeSignature(Challenge), + InvalidChallengeSignature(Box), /// The Service channel has been closed early. ServiceChannelClosed, /// The discv5 service is not running. diff --git a/src/handler/mod.rs b/src/handler/mod.rs index ac566adf..37c8cb23 100644 --- a/src/handler/mod.rs +++ b/src/handler/mod.rs @@ -784,10 +784,10 @@ impl Handler { && match node_address.socket_addr { SocketAddr::V4(socket_addr) => enr .udp4_socket() - .map_or(true, |advertized_addr| socket_addr == advertized_addr), + .is_none_or(|advertized_addr| socket_addr == advertized_addr), SocketAddr::V6(socket_addr) => enr .udp6_socket() - .map_or(true, |advertized_addr| socket_addr == advertized_addr), + .is_none_or(|advertized_addr| socket_addr == advertized_addr), } } @@ -893,7 +893,7 @@ impl Handler { "Authentication header contained invalid signature. Ignoring packet from node", ); // insert back the challenge - self.active_challenges.insert(node_address, challenge); + self.active_challenges.insert(node_address, *challenge); } Err(e) => { warn!( diff --git a/src/handler/session.rs b/src/handler/session.rs index 7f3a0ef4..463b5210 100644 --- a/src/handler/session.rs +++ b/src/handler/session.rs @@ -174,7 +174,7 @@ impl Session { local_id, id_nonce_sig, ) { - return Err(Error::InvalidChallengeSignature(challenge)); + return Err(Error::InvalidChallengeSignature(Box::new(challenge))); } // The keys are derived after the message has been verified to prevent potential extra work diff --git a/src/kbucket.rs b/src/kbucket.rs index 1489a7bd..8d9a98d6 100644 --- a/src/kbucket.rs +++ b/src/kbucket.rs @@ -423,18 +423,16 @@ where let update_value = bucket.update_value(key, value); match (update_value, update_status) { - (UpdateResult::Updated { .. }, UpdateResult::Updated) => { - InsertResult::Updated { - promoted_to_connected: false, - } - } - (UpdateResult::Updated { .. }, UpdateResult::UpdatedAndPromoted) => { + (UpdateResult::Updated, UpdateResult::Updated) => InsertResult::Updated { + promoted_to_connected: false, + }, + (UpdateResult::Updated, UpdateResult::UpdatedAndPromoted) => { InsertResult::Updated { promoted_to_connected: true, } } - (UpdateResult::Updated { .. }, UpdateResult::NotModified) - | (UpdateResult::Updated { .. }, UpdateResult::UpdatedPending) => { + (UpdateResult::Updated, UpdateResult::NotModified) + | (UpdateResult::Updated, UpdateResult::UpdatedPending) => { InsertResult::ValueUpdated } (UpdateResult::NotModified, UpdateResult::Updated) => { diff --git a/src/service/connectivity_state.rs b/src/service/connectivity_state.rs index f7f23d31..2779fd11 100644 --- a/src/service/connectivity_state.rs +++ b/src/service/connectivity_state.rs @@ -11,11 +11,11 @@ //! 1. Our ENR socket gets updated //! 2. This triggers us to set an incoming wait timer //! 3. a. If we receive an incoming connection within this time, we consider ourselves contactable -//! and we remove the timer. +//! and we remove the timer. //! 3. b. If we don't receive a connection and the timer expires. If the timer expires, we set our -//! external ENR address to None and set the `next_connectivity_test` to -//! DURATION_UNTIL_NEXT_CONNECTIVITY_ATTEMPT in the future. This will prevent counting votes until -//! this time, which prevents our ENR from being updated. +//! external ENR address to None and set the `next_connectivity_test` to +//! DURATION_UNTIL_NEXT_CONNECTIVITY_ATTEMPT in the future. This will prevent counting votes until +//! this time, which prevents our ENR from being updated. use crate::metrics::METRICS; use futures::{