Use `VoteAccount::node_pubkey()` (#26207)

This commit is contained in:
Brooks Prumo 2022-06-27 09:09:06 -05:00 committed by GitHub
parent d5efbdb19b
commit 662818ef0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 9 deletions

View File

@ -1995,11 +1995,7 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
if activated_stake == 0 {
continue;
}
let vote_state_node_pubkey = vote_account
.vote_state()
.as_ref()
.map(|vote_state| vote_state.node_pubkey)
.unwrap_or_default();
let vote_state_node_pubkey = vote_account.node_pubkey().unwrap_or_default();
if let Some(peer) = peers.get(&vote_state_node_pubkey) {
if peer.shred_version == my_shred_version {

View File

@ -5051,8 +5051,9 @@ impl Bank {
None
} else {
total_staked += *staked;
let node_pubkey = account.vote_state().as_ref().ok()?.node_pubkey;
Some((node_pubkey, *staked))
account
.node_pubkey()
.map(|node_pubkey| (node_pubkey, *staked))
}
})
.collect::<Vec<(Pubkey, u64)>>();

View File

@ -378,7 +378,7 @@ impl Stakes<StakeAccount> {
pub(crate) fn highest_staked_node(&self) -> Option<Pubkey> {
let vote_account = self.vote_accounts.find_max_by_delegated_stake()?;
Some(vote_account.vote_state().as_ref().ok()?.node_pubkey)
vote_account.node_pubkey()
}
}

View File

@ -93,7 +93,7 @@ impl VoteAccount {
}
/// VoteState.node_pubkey of this vote-account.
fn node_pubkey(&self) -> Option<Pubkey> {
pub fn node_pubkey(&self) -> Option<Pubkey> {
Some(self.vote_state().as_ref().ok()?.node_pubkey)
}
}