Skip to content

Commit

Permalink
Fix seed thread crash (mimblewimble#2096)
Browse files Browse the repository at this point in the history
We get overflow in some tests, peraps in real life too
Fixes mimblewimble#2095
  • Loading branch information
hashmap authored Dec 7, 2018
1 parent d1b4842 commit a6bb634
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion p2p/src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ impl Peers {
}

// ensure we do not still have too many connected peers
let excess_count = (self.peer_count() as usize - rm.len()).saturating_sub(max_count);
let excess_count = (self.peer_count() as usize)
.saturating_sub(rm.len())
.saturating_sub(max_count);
if excess_count > 0 {
// map peers to addrs in a block to bound how long we keep the read lock for
let mut addrs = self
Expand Down

0 comments on commit a6bb634

Please sign in to comment.