Skip to content

Commit

Permalink
pr: ignore clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo committed Jun 26, 2022
1 parent 877feda commit edd1a9d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ impl Tower {
continue;
}
trace!("{} {} with stake {}", vote_account_pubkey, key, voted_stake);

// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
#[allow(clippy::significant_drop_in_scrutinee)]
let mut vote_state = match account.vote_state().as_ref() {
Err(_) => {
datapoint_warn!(
Expand Down
4 changes: 4 additions & 0 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,11 @@ impl ReplayStage {
}
Some((_stake, vote_account)) => vote_account,
};

let vote_state = vote_account.vote_state();
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
#[allow(clippy::significant_drop_in_scrutinee)]
let vote_state = match vote_state.as_ref() {
Err(_) => {
warn!(
Expand Down
6 changes: 1 addition & 5 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1956,11 +1956,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
3 changes: 3 additions & 0 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,9 @@ fn supermajority_root_from_vote_accounts(
return None;
}

// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
#[allow(clippy::significant_drop_in_scrutinee)]
match account.vote_state().as_ref() {
Err(_) => {
warn!(
Expand Down
6 changes: 5 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2977,6 +2977,10 @@ impl Bank {
invalid_vote_keys.insert(vote_pubkey, InvalidCacheEntryReason::WrongOwner);
return None;
}

// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
#[allow(clippy::significant_drop_in_scrutinee)]
let vote_state = match vote_account.vote_state().deref() {
Ok(vote_state) => vote_state.clone(),
Err(_) => {
Expand Down Expand Up @@ -5043,7 +5047,7 @@ impl Bank {
None
} else {
total_staked += *staked;
let node_pubkey = account.vote_state().as_ref().ok()?.node_pubkey;
let node_pubkey = account.node_pubkey()?;
Some((node_pubkey, *staked))
}
})
Expand Down
3 changes: 3 additions & 0 deletions runtime/src/epoch_stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ impl EpochStakes {
.iter()
.filter_map(|(key, (stake, account))| {
let vote_state = account.vote_state();
// NOTE: `.vote_state()` grabs a reader lock, but there will never be any writers
// (since the only writer was within a `Once`), so we can ignore this clippy warning.
#[allow(clippy::significant_drop_in_scrutinee)]
let vote_state = match vote_state.as_ref() {
Err(_) => {
datapoint_warn!(
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Stakes<StakeAccount> {
pub(crate) fn highest_staked_node(&self) -> Option<Pubkey> {
let key = |(_pubkey, (stake, _vote_account)): &(_, &(u64, _))| *stake;
let (_pubkey, (_stake, vote_account)) = self.vote_accounts.iter().max_by_key(key)?;
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 edd1a9d

Please sign in to comment.