diff --git a/src/kbucket/bucket.rs b/src/kbucket/bucket.rs index b943f9661..c49a794c4 100644 --- a/src/kbucket/bucket.rs +++ b/src/kbucket/bucket.rs @@ -90,8 +90,8 @@ impl PendingNode { self.node.status } - pub fn value_mut(&mut self) -> &mut TVal { - &mut self.node.value + pub fn value(&self) -> &TVal { + &self.node.value } pub fn set_ready_at(&mut self, t: Instant) { diff --git a/src/kbucket/entry.rs b/src/kbucket/entry.rs index 97be95de1..72c4ac04b 100644 --- a/src/kbucket/entry.rs +++ b/src/kbucket/entry.rs @@ -175,12 +175,12 @@ where } /// Returns the value associated with the key. - pub fn value(&mut self) -> &mut TVal { + pub fn value(&self) -> &TVal { self.0 .bucket - .pending_mut() + .pending() .expect("We can only build a ConnectedPendingEntry if the entry is pending; QED") - .value_mut() + .value() } /// Updates the status of the pending entry. diff --git a/src/query_pool/peers/closest.rs b/src/query_pool/peers/closest.rs index 334d8a39f..58373f2d1 100644 --- a/src/query_pool/peers/closest.rs +++ b/src/query_pool/peers/closest.rs @@ -324,8 +324,8 @@ where /// Consumes the query, returning the target and the closest peers. pub fn into_result(self) -> Vec { self.closest_peers - .into_iter() - .filter_map(|(_, peer)| { + .into_values() + .filter_map(|peer| { if let QueryPeerState::Succeeded = peer.state { Some(peer.key.into_preimage()) } else { diff --git a/src/query_pool/peers/predicate.rs b/src/query_pool/peers/predicate.rs index 3b4442019..c1f2aa128 100644 --- a/src/query_pool/peers/predicate.rs +++ b/src/query_pool/peers/predicate.rs @@ -314,8 +314,8 @@ where /// Consumes the query, returning the peers who match the predicate. pub fn into_result(self) -> Vec { self.closest_peers - .into_iter() - .filter_map(|(_, peer)| { + .into_values() + .filter_map(|peer| { if let QueryPeerState::Succeeded = peer.state { if peer.predicate_match { Some(peer.key.into_preimage()) diff --git a/src/service.rs b/src/service.rs index 10b26d31d..3b8b8d6f3 100644 --- a/src/service.rs +++ b/src/service.rs @@ -616,17 +616,13 @@ impl Service { // check if we need to update the known ENR let mut to_request_enr = None; match self.kbuckets.write().entry(&node_address.node_id.into()) { - kbucket::Entry::Present(ref mut entry, _) => { - if entry.value().seq() < enr_seq { - let enr = entry.value().clone(); - to_request_enr = Some(enr); - } + kbucket::Entry::Present(ref entry, _) if entry.value().seq() < enr_seq => { + let enr = entry.value().clone(); + to_request_enr = Some(enr); } - kbucket::Entry::Pending(ref mut entry, _) => { - if entry.value().seq() < enr_seq { - let enr = entry.value().clone(); - to_request_enr = Some(enr); - } + kbucket::Entry::Pending(ref entry, _) if entry.value().seq() < enr_seq => { + let enr = entry.value().clone(); + to_request_enr = Some(enr); } // don't know the peer, don't request its most recent ENR _ => {} @@ -1276,7 +1272,7 @@ impl Service { let must_update_enr = match self.kbuckets.write().entry(&key) { kbucket::Entry::Present(entry, _) => entry.value().seq() < enr.seq(), - kbucket::Entry::Pending(mut entry, _) => entry.value().seq() < enr.seq(), + kbucket::Entry::Pending(entry, _) => entry.value().seq() < enr.seq(), _ => false, }; @@ -1297,10 +1293,8 @@ impl Service { kbucket::Entry::Present(entry, _) if entry.value().seq() < enr.seq() => { entry.remove() } - kbucket::Entry::Pending(mut entry, _) => { - if entry.value().seq() < enr.seq() { - entry.remove() - } + kbucket::Entry::Pending(entry, _) if entry.value().seq() < enr.seq() => { + entry.remove() } _ => {} }