Skip to content

Commit

Permalink
chore: Use IndexMap::shift_remove
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Jul 5, 2024
1 parent 6b834e3 commit e0cfccd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/p2p/bitswap/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl WantSession {

pub fn dont_have_block(&mut self, peer_id: PeerId) {
tracing::trace!(session = %self.cid, %peer_id, name = "want_session", "dont have block");
self.wants.swap_remove(&peer_id);
self.wants.shift_remove(&peer_id);

if self.is_empty() {
self.state = WantSessionState::Idle;
Expand Down Expand Up @@ -171,7 +171,7 @@ impl WantSession {
let state = entry.get_mut();
if let PeerWantState::Disconnect { backoff } = state {
if *backoff {
entry.swap_remove();
entry.shift_remove();
}
return false;
} else {
Expand Down Expand Up @@ -203,7 +203,7 @@ impl WantSession {
pub fn remove_peer(&mut self, peer_id: PeerId) {
if !self.is_empty() {
// tracing::debug!(session = %self.cid, %peer_id, name = "want_session", "removing peer from want_session");
self.wants.swap_remove(&peer_id);
self.wants.shift_remove(&peer_id);

if matches!(self.state, WantSessionState::NextBlockPending { peer_id: p, .. } if p == peer_id)
{
Expand Down

0 comments on commit e0cfccd

Please sign in to comment.