Skip to content

Commit

Permalink
Update src/client.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Maciej Zwoliński <[email protected]>
  • Loading branch information
oblique and zvolin authored Jan 25, 2024
1 parent 405464f commit 995eed5
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,13 @@ where
}

pub(crate) fn new_connection_handler(&mut self, peer: PeerId) -> ClientConnectionHandler<S> {
match self.peers.entry(peer) {
hash_map::Entry::Occupied(mut entry) => {
entry.get_mut().established_connections_num += 1;
}
hash_map::Entry::Vacant(entry) => {
entry.insert(PeerState {
established_connections_num: 1,
sending: Arc::new(Mutex::new(SendingState::Ready)),
wantlist: WantlistState::new(),
send_full: true,
});
}
}
let peer = self.peers.entry(peer).or_insert_with(|| PeerState {
established_connections_num: 0,
sending: Arc::new(Mutex::new(SendingState::Ready)),
wantlist: WantlistState::new(),
send_full: true,
});
peer.established_connections_num += 1;

ClientConnectionHandler {
protocol: self.protocol.clone(),
Expand Down

0 comments on commit 995eed5

Please sign in to comment.