Use rank_stakes() in LeaderScheduler

This commit is contained in:
Greg Fitzgerald 2019-02-20 11:51:45 -07:00
parent cf163a9dab
commit 1c2169aec7
2 changed files with 3 additions and 10 deletions

View File

@ -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.

View File

@ -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
}