Cleanup stakes for gossip (#2860)

This commit is contained in:
Sagar Dhawan
2019-02-20 20:02:47 -08:00
committed by GitHub
parent 1cd88968cf
commit 3c62e2332e
6 changed files with 82 additions and 71 deletions

View File

@ -8,6 +8,7 @@ use crate::last_id_queue::LastIdQueue;
use crate::runtime::{self, RuntimeError};
use crate::status_cache::StatusCache;
use bincode::{deserialize, serialize};
use hashbrown::HashMap;
use log::{debug, info, Level};
use solana_metrics::counter::Counter;
use solana_sdk::account::Account;
@ -596,6 +597,16 @@ impl Bank {
.collect()
}
/// Collect all the stakes into a Map keyed on the Node id.
pub fn get_stakes(&self) -> HashMap<Pubkey, u64> {
let map: HashMap<_, _> = self
.vote_states(|_| true)
.iter()
.map(|state| (state.node_id, self.get_balance(&state.staker_id)))
.collect();
map
}
pub fn tick_height(&self) -> u64 {
self.last_id_queue.read().unwrap().tick_height
}