Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Use VoteAccount::node_pubkey() (#26207)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Jun 27, 2022
1 parent d5efbdb commit 662818e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
6 changes: 1 addition & 5 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>>();
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/vote_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 662818e

Please sign in to comment.