Fix really old banks triggering log spam (#6025)
This commit is contained in:
parent
dbd337c616
commit
62c22c6cb1
|
@ -253,6 +253,16 @@ impl Tower {
|
|||
sum
|
||||
}
|
||||
|
||||
// a slot is not recent if its older than the oldest lockout we have
|
||||
pub fn is_recent(&self, slot: u64) -> bool {
|
||||
if let Some(oldest_vote) = self.lockouts.votes.front() {
|
||||
if slot < oldest_vote.slot {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn has_voted(&self, slot: u64) -> bool {
|
||||
for vote in &self.lockouts.votes {
|
||||
if vote.slot == slot {
|
||||
|
@ -590,6 +600,19 @@ mod test {
|
|||
assert!(!tower.has_voted(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_recent_slot() {
|
||||
let mut tower = Tower::new_for_tests(0, 0.67);
|
||||
assert!(tower.is_recent(0));
|
||||
assert!(tower.is_recent(32));
|
||||
for i in 0..64 {
|
||||
tower.record_vote(i, Hash::default());
|
||||
}
|
||||
assert!(!tower.is_recent(0));
|
||||
assert!(!tower.is_recent(32));
|
||||
assert!(tower.is_recent(65));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_locked_out_double_vote() {
|
||||
let mut tower = Tower::new_for_tests(0, 0.67);
|
||||
|
|
|
@ -574,6 +574,11 @@ impl ReplayStage {
|
|||
trace!("bank is votable: {} {}", b.slot(), is_votable);
|
||||
is_votable
|
||||
})
|
||||
.filter(|b| {
|
||||
let is_recent = tower.is_recent(b.slot());
|
||||
trace!("tower is recent: {} {}", b.slot(), is_recent);
|
||||
is_recent
|
||||
})
|
||||
.filter(|b| {
|
||||
let has_voted = tower.has_voted(b.slot());
|
||||
trace!("bank has_voted: {} {}", b.slot(), has_voted);
|
||||
|
|
Loading…
Reference in New Issue