Skip to content

Commit

Permalink
fixing #8113
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyakovenko committed Feb 4, 2020
1 parent 4e595e8 commit c8d0dc0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,40 @@ impl Tower {
}
}

pub fn observed_vote_distribution(
vote_accounts: &HashMap<Pubkey, (u64, Account)>,
) -> HashMap<Slot, HashMap<Pubkey, Lockout>> {
let mut votes = HashMap::new();
for (key, (lamports, account)) in vote_accounts.iter() {
let vote_state = VoteState::from(&account);
if vote_state.is_none() {
datapoint_warn!(
"tower_warn",
(
"warn",
format!("Unable to get vote_state from account {}", key),
String
),
);
continue;
}
let mut vote_state = vote_state.unwrap();
for vote in &vote_state.votes {
votes
.entry(vote.slot())
.or_default()
.insert(key, vote.lockout());
}
if let Some(slot) = vote_state.root_slot {
votes
.entry(slot)
.or_default()
.insert(key, MAX_LOCKOUT_HISTORY);
}
}
votes
}

pub fn collect_vote_lockouts<F>(
&self,
bank_slot: u64,
Expand Down

0 comments on commit c8d0dc0

Please sign in to comment.