Remove get_confirmation_timestamp() from HashQueue

This commit is contained in:
Michael Vines
2019-03-01 13:13:32 -08:00
parent fdc31e99df
commit e30e4cc603
3 changed files with 27 additions and 39 deletions

View File

@@ -37,30 +37,22 @@ impl LeaderConfirmationService {
// the vote states
let vote_states = bank.vote_states(|_, vote_state| leader_id != vote_state.delegate_id);
let mut ticks_and_stakes: Vec<(u64, u64)> = vote_states
let slots_and_stakes: Vec<(u64, u64)> = vote_states
.iter()
.filter_map(|(_, vote_state)| {
let validator_stake = bank.get_balance(&vote_state.delegate_id);
total_stake += validator_stake;
// Filter out any validators that don't have at least one vote
// by returning None
vote_state
.votes
.back()
// A vote for a slot is like a vote for the last tick in that slot
.map(|vote| {
(
(vote.slot_height + 1) * bank.ticks_per_slot() - 1,
validator_stake,
)
})
.map(|vote| (vote.slot_height, validator_stake))
})
.collect();
let super_majority_stake = (2 * total_stake) / 3;
if let Some(last_valid_validator_timestamp) =
bank.get_confirmation_timestamp(&mut ticks_and_stakes, super_majority_stake)
bank.get_confirmation_timestamp(slots_and_stakes, super_majority_stake)
{
return Ok(last_valid_validator_timestamp);
}