diff --git a/src/active_stakers.rs b/src/active_stakers.rs index 8608ce8ce7..92768a995a 100644 --- a/src/active_stakers.rs +++ b/src/active_stakers.rs @@ -15,7 +15,7 @@ fn is_active_staker(vote_state: &VoteState, lower_bound: u64, upper_bound: u64) .is_some() } -fn rank_stakes(stakes: &mut Vec<(Pubkey, u64)>) { +pub fn rank_stakes(stakes: &mut Vec<(Pubkey, u64)>) { // Rank first by stake. If stakes are the same we rank by pubkey to ensure a // deterministic result. // Note: Use unstable sort, because we dedup right after to remove the equal elements. diff --git a/src/leader_scheduler.rs b/src/leader_scheduler.rs index 5d6ede4232..109cc39211 100644 --- a/src/leader_scheduler.rs +++ b/src/leader_scheduler.rs @@ -1,7 +1,7 @@ //! The `leader_scheduler` module implements a structure and functions for tracking and //! managing the schedule for leader rotation -use crate::active_stakers::{ActiveStakers, DEFAULT_ACTIVE_WINDOW_TICK_LENGTH}; +use crate::active_stakers::{self, ActiveStakers, DEFAULT_ACTIVE_WINDOW_TICK_LENGTH}; use crate::entry::{create_ticks, next_entry_mut, Entry}; use crate::voting_keypair::VotingKeypair; use bincode::serialize; @@ -300,14 +300,7 @@ impl LeaderScheduler { } }) .collect(); - - active_accounts.sort_by(|(pubkey1, stake1), (pubkey2, stake2)| { - if stake1 == stake2 { - pubkey1.cmp(&pubkey2) - } else { - stake1.cmp(&stake2) - } - }); + active_stakers::rank_stakes(&mut active_accounts); active_accounts }