filter out banks that have an older epoch (#3472)

This commit is contained in:
anatoly yakovenko
2019-03-25 11:09:39 -07:00
committed by GitHub
parent 5c536e423c
commit 51004881f8
2 changed files with 21 additions and 1 deletions

View File

@@ -142,13 +142,28 @@ impl Locktower {
stake_lockouts
}
pub fn is_recent_epoch(&self, bank: &Bank) -> bool {
let bank_epoch = bank.get_epoch_and_slot_index(bank.slot()).0;
bank_epoch >= self.epoch_stakes.slot
}
pub fn update_epoch(&mut self, bank: &Bank) {
trace!(
"updating bank epoch {} {}",
bank.slot(),
self.epoch_stakes.slot
);
let bank_epoch = bank.get_epoch_and_slot_index(bank.slot()).0;
if bank_epoch != self.epoch_stakes.slot {
assert!(
bank_epoch > self.epoch_stakes.slot,
self.is_recent_epoch(bank),
"epoch_stakes cannot move backwards"
);
info!(
"Locktower updated epoch bank {} {}",
bank.slot(),
self.epoch_stakes.slot
);
self.epoch_stakes = EpochStakes::new_from_bank(bank);
}
}