Fix slot index used while calculating leader schedule

- slot_leader_at() was using absolute slot number instead of index in the epoch
This commit is contained in:
Pankaj Garg 2019-02-28 15:18:08 -08:00 committed by Grimes
parent 1c44b738fe
commit 30bccc0c68
1 changed files with 3 additions and 2 deletions

View File

@ -36,8 +36,9 @@ pub fn slot_leader(bank: &Bank) -> Pubkey {
/// Return the leader for the given slot.
pub fn slot_leader_at(slot: u64, bank: &Bank) -> Pubkey {
let epoch = slot / bank.slots_per_epoch();
slot_leader_by(bank, |_, _, _| (slot, epoch))
slot_leader_by(bank, |_, _, _| {
(slot % bank.slots_per_epoch(), slot / bank.slots_per_epoch())
})
}
/// Return the epoch height and slot index of the slot before the current slot.