Skip to content

Commit

Permalink
A default tower is no longer considered to contain a stray last vote
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jun 10, 2022
1 parent 2251aa2 commit ace24a7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ impl Tower {
}

pub fn is_stray_last_vote(&self) -> bool {
self.stray_restored_slot == self.last_voted_slot()
self.stray_restored_slot.is_some() && self.stray_restored_slot == self.last_voted_slot()
}

// The tower root can be older/newer if the validator booted from a newer/older snapshot, so
Expand Down Expand Up @@ -3242,4 +3242,10 @@ pub mod test {
assert_eq!(tower.voted_slots(), vec![13, 14]);
assert_eq!(tower.stray_restored_slot, Some(14));
}

#[test]
fn test_default_tower_has_no_stray_last_vote() {
let tower = Tower::default();
assert!(!tower.is_stray_last_vote());
}
}

0 comments on commit ace24a7

Please sign in to comment.