Skip to content

Commit

Permalink
Merge pull request #1044 from jjyr/fix-peer-addr-isterrible
Browse files Browse the repository at this point in the history
fix: peer_store time calculation overflow
  • Loading branch information
doitian committed Jun 17, 2019
2 parents 97ed7e3 + d168b0f commit 190e9f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions network/src/peer_store/types.rs
Expand Up @@ -55,7 +55,7 @@ impl PeerAddr {
}

pub fn tried_in_last_minute(&self, now_ms: u64) -> bool {
self.last_tried_at_ms >= (now_ms - 60_000)
self.last_tried_at_ms >= now_ms.saturating_sub(60_000)
}

pub fn is_terrible(&self, now_ms: u64) -> bool {
Expand All @@ -68,7 +68,7 @@ impl PeerAddr {
return true;
}
// consider addr is terrible if failed too many times
if (now_ms - self.last_connected_at_ms) > ADDR_TIMEOUT_MS
if now_ms.saturating_sub(self.last_connected_at_ms) > ADDR_TIMEOUT_MS
&& (self.attempts_count >= ADDR_MAX_FAILURES)
{
return true;
Expand Down

0 comments on commit 190e9f2

Please sign in to comment.