next_leader_slot is doing a linear search for slots in which a pubkey is
the leader:
https://github.com/solana-labs/solana/blob/e59a24d9f/ledger/src/leader_schedule_cache.rs#L123-L157
This can be done more efficiently by adding an inverted index to leader
schedule.
(cherry picked from commit e403aeaf05
)
Co-authored-by: behzad nouri <behzadnouri@gmail.com>