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

Commit 662818e

Browse files
authored
Use VoteAccount::node_pubkey() (#26207)
1 parent d5efbdb commit 662818e

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

core/src/validator.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,11 +1995,7 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
19951995
if activated_stake == 0 {
19961996
continue;
19971997
}
1998-
let vote_state_node_pubkey = vote_account
1999-
.vote_state()
2000-
.as_ref()
2001-
.map(|vote_state| vote_state.node_pubkey)
2002-
.unwrap_or_default();
1998+
let vote_state_node_pubkey = vote_account.node_pubkey().unwrap_or_default();
20031999

20042000
if let Some(peer) = peers.get(&vote_state_node_pubkey) {
20052001
if peer.shred_version == my_shred_version {

runtime/src/bank.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5051,8 +5051,9 @@ impl Bank {
50515051
None
50525052
} else {
50535053
total_staked += *staked;
5054-
let node_pubkey = account.vote_state().as_ref().ok()?.node_pubkey;
5055-
Some((node_pubkey, *staked))
5054+
account
5055+
.node_pubkey()
5056+
.map(|node_pubkey| (node_pubkey, *staked))
50565057
}
50575058
})
50585059
.collect::<Vec<(Pubkey, u64)>>();

runtime/src/stakes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl Stakes<StakeAccount> {
378378

379379
pub(crate) fn highest_staked_node(&self) -> Option<Pubkey> {
380380
let vote_account = self.vote_accounts.find_max_by_delegated_stake()?;
381-
Some(vote_account.vote_state().as_ref().ok()?.node_pubkey)
381+
vote_account.node_pubkey()
382382
}
383383
}
384384

runtime/src/vote_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl VoteAccount {
9393
}
9494

9595
/// VoteState.node_pubkey of this vote-account.
96-
fn node_pubkey(&self) -> Option<Pubkey> {
96+
pub fn node_pubkey(&self) -> Option<Pubkey> {
9797
Some(self.vote_state().as_ref().ok()?.node_pubkey)
9898
}
9999
}

0 commit comments

Comments
 (0)