timestamp fix

This commit is contained in:
John Smith
2022-12-10 13:36:26 -05:00
parent 6753fe01a1
commit 572f0f23ed
8 changed files with 13 additions and 13 deletions

View File

@@ -1346,19 +1346,19 @@ impl NetworkManager {
let ts = get_timestamp();
let ets = envelope.get_timestamp();
if let Some(tsbehind) = tsbehind {
if tsbehind > 0 && (ts > ets && ts - ets > tsbehind) {
if tsbehind > 0 && (ts > ets && ts.saturating_sub(ets) > tsbehind) {
log_net!(debug
"envelope time was too far in the past: {}ms ",
timestamp_to_secs(ts - ets) * 1000f64
timestamp_to_secs(ts.saturating_sub(ets)) * 1000f64
);
return Ok(false);
}
}
if let Some(tsahead) = tsahead {
if tsahead > 0 && (ts < ets && ets - ts > tsahead) {
if tsahead > 0 && (ts < ets && ets.saturating_sub(ts) > tsahead) {
log_net!(debug
"envelope time was too far in the future: {}ms",
timestamp_to_secs(ets - ts) * 1000f64
timestamp_to_secs(ets.saturating_sub(ts)) * 1000f64
);
return Ok(false);
}

View File

@@ -30,7 +30,7 @@ impl NetworkManager {
);
// While we're here, lets see if this address has timed out
if cur_ts - stats.last_seen_ts >= IPADDR_MAX_INACTIVE_DURATION_US {
if cur_ts.saturating_sub(stats.last_seen_ts) >= IPADDR_MAX_INACTIVE_DURATION_US {
// it's dead, put it in the dead list
dead_addrs.insert(*addr);
}