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

Commit edd1a9d

Browse files
committed
pr: ignore clippy warnings
1 parent 877feda commit edd1a9d

File tree

8 files changed

+22
-8
lines changed

8 files changed

+22
-8
lines changed

core/src/consensus.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ impl Tower {
271271
continue;
272272
}
273273
trace!("{} {} with stake {}", vote_account_pubkey, key, voted_stake);
274+
275+
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
276+
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
277+
#[allow(clippy::significant_drop_in_scrutinee)]
274278
let mut vote_state = match account.vote_state().as_ref() {
275279
Err(_) => {
276280
datapoint_warn!(

core/src/replay_stage.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,11 @@ impl ReplayStage {
19181918
}
19191919
Some((_stake, vote_account)) => vote_account,
19201920
};
1921+
19211922
let vote_state = vote_account.vote_state();
1923+
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
1924+
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
1925+
#[allow(clippy::significant_drop_in_scrutinee)]
19221926
let vote_state = match vote_state.as_ref() {
19231927
Err(_) => {
19241928
warn!(

core/src/validator.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,11 +1956,7 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
19561956
if activated_stake == 0 {
19571957
continue;
19581958
}
1959-
let vote_state_node_pubkey = vote_account
1960-
.vote_state()
1961-
.as_ref()
1962-
.map(|vote_state| vote_state.node_pubkey)
1963-
.unwrap_or_default();
1959+
let vote_state_node_pubkey = vote_account.node_pubkey().unwrap_or_default();
19641960

19651961
if let Some(peer) = peers.get(&vote_state_node_pubkey) {
19661962
if peer.shred_version == my_shred_version {

ledger/src/blockstore_processor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,9 @@ fn supermajority_root_from_vote_accounts(
14621462
return None;
14631463
}
14641464

1465+
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
1466+
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
1467+
#[allow(clippy::significant_drop_in_scrutinee)]
14651468
match account.vote_state().as_ref() {
14661469
Err(_) => {
14671470
warn!(

runtime/src/bank.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2977,6 +2977,10 @@ impl Bank {
29772977
invalid_vote_keys.insert(vote_pubkey, InvalidCacheEntryReason::WrongOwner);
29782978
return None;
29792979
}
2980+
2981+
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
2982+
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
2983+
#[allow(clippy::significant_drop_in_scrutinee)]
29802984
let vote_state = match vote_account.vote_state().deref() {
29812985
Ok(vote_state) => vote_state.clone(),
29822986
Err(_) => {
@@ -5043,7 +5047,7 @@ impl Bank {
50435047
None
50445048
} else {
50455049
total_staked += *staked;
5046-
let node_pubkey = account.vote_state().as_ref().ok()?.node_pubkey;
5050+
let node_pubkey = account.node_pubkey()?;
50475051
Some((node_pubkey, *staked))
50485052
}
50495053
})

runtime/src/epoch_stakes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ impl EpochStakes {
7373
.iter()
7474
.filter_map(|(key, (stake, account))| {
7575
let vote_state = account.vote_state();
76+
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
77+
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
78+
#[allow(clippy::significant_drop_in_scrutinee)]
7679
let vote_state = match vote_state.as_ref() {
7780
Err(_) => {
7881
datapoint_warn!(

runtime/src/stakes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl Stakes<StakeAccount> {
379379
pub(crate) fn highest_staked_node(&self) -> Option<Pubkey> {
380380
let key = |(_pubkey, (stake, _vote_account)): &(_, &(u64, _))| *stake;
381381
let (_pubkey, (_stake, vote_account)) = self.vote_accounts.iter().max_by_key(key)?;
382-
Some(vote_account.vote_state().as_ref().ok()?.node_pubkey)
382+
vote_account.node_pubkey()
383383
}
384384
}
385385

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)