Check distance for timestamp
This commit is contained in:
committed by
Michael Vines
parent
840ebfe625
commit
db6540772c
@ -202,6 +202,14 @@ pub fn make_accounts_hashes_message(
|
|||||||
Some(CrdsValue::new_signed(message, keypair))
|
Some(CrdsValue::new_signed(message, keypair))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn distance(a: u64, b: u64) -> u64 {
|
||||||
|
if a > b {
|
||||||
|
a - b
|
||||||
|
} else {
|
||||||
|
b - a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO These messages should go through the gpu pipeline for spam filtering
|
// TODO These messages should go through the gpu pipeline for spam filtering
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
@ -1032,7 +1040,7 @@ impl ClusterInfo {
|
|||||||
let mut num_live_peers = 1i64;
|
let mut num_live_peers = 1i64;
|
||||||
peers.iter().for_each(|p| {
|
peers.iter().for_each(|p| {
|
||||||
// A peer is considered live if they generated their contact info recently
|
// A peer is considered live if they generated their contact info recently
|
||||||
if timestamp() - p.wallclock <= CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS {
|
if distance(timestamp(), p.wallclock) <= CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS {
|
||||||
num_live_peers += 1;
|
num_live_peers += 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user