Refactor: No need to return stake in Bank::get_vote_account (#26220)
This commit is contained in:
parent
f1b82ec44d
commit
44d1e62007
|
@ -489,7 +489,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_highest_confirmed_root_advance() {
|
||||
fn get_vote_account_root_slot(vote_pubkey: Pubkey, bank: &Arc<Bank>) -> Slot {
|
||||
let (_stake, vote_account) = bank.get_vote_account(&vote_pubkey).unwrap();
|
||||
let vote_account = bank.get_vote_account(&vote_pubkey).unwrap();
|
||||
let slot = vote_account
|
||||
.vote_state()
|
||||
.as_ref()
|
||||
|
|
|
@ -438,7 +438,7 @@ impl Tower {
|
|||
}
|
||||
|
||||
pub fn last_voted_slot_in_bank(bank: &Bank, vote_account_pubkey: &Pubkey) -> Option<Slot> {
|
||||
let (_stake, vote_account) = bank.get_vote_account(vote_account_pubkey)?;
|
||||
let vote_account = bank.get_vote_account(vote_account_pubkey)?;
|
||||
let vote_state = vote_account.vote_state();
|
||||
vote_state.as_ref().ok()?.last_voted_slot()
|
||||
}
|
||||
|
@ -1239,7 +1239,7 @@ impl Tower {
|
|||
root: Slot,
|
||||
bank: &Bank,
|
||||
) {
|
||||
if let Some((_stake, vote_account)) = bank.get_vote_account(vote_account_pubkey) {
|
||||
if let Some(vote_account) = bank.get_vote_account(vote_account_pubkey) {
|
||||
self.vote_state = vote_account
|
||||
.vote_state()
|
||||
.as_ref()
|
||||
|
@ -2034,7 +2034,7 @@ pub mod test {
|
|||
.unwrap()
|
||||
.get_vote_account(&vote_pubkey)
|
||||
.unwrap();
|
||||
let state = observed.1.vote_state();
|
||||
let state = observed.vote_state();
|
||||
info!("observed tower: {:#?}", state.as_ref().unwrap().votes);
|
||||
|
||||
let num_slots_to_try = 200;
|
||||
|
|
|
@ -1916,7 +1916,7 @@ impl ReplayStage {
|
|||
);
|
||||
return None;
|
||||
}
|
||||
Some((_stake, vote_account)) => vote_account,
|
||||
Some(vote_account) => vote_account,
|
||||
};
|
||||
let vote_state = vote_account.vote_state();
|
||||
let vote_state = match vote_state.as_ref() {
|
||||
|
@ -2411,7 +2411,7 @@ impl ReplayStage {
|
|||
if !is_computed {
|
||||
// Check if our tower is behind, if so (and the feature migration flag is in use)
|
||||
// overwrite with the newer bank.
|
||||
if let (true, Some((_, vote_account))) = (
|
||||
if let (true, Some(vote_account)) = (
|
||||
Tower::is_direct_vote_state_update_enabled(bank),
|
||||
bank.get_vote_account(my_vote_pubkey),
|
||||
) {
|
||||
|
@ -6107,7 +6107,7 @@ pub(crate) mod tests {
|
|||
expired_bank.slot() + 1,
|
||||
));
|
||||
expired_bank_child.process_transaction(vote_tx).unwrap();
|
||||
let (_stake, vote_account) = expired_bank_child
|
||||
let vote_account = expired_bank_child
|
||||
.get_vote_account(&my_vote_pubkey)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
|
|
|
@ -105,7 +105,7 @@ impl VoteSimulator {
|
|||
let vote_account = new_bank
|
||||
.get_vote_account(&keypairs.vote_keypair.pubkey())
|
||||
.unwrap();
|
||||
let state = vote_account.1.vote_state();
|
||||
let state = vote_account.vote_state();
|
||||
assert!(state
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
|
|
|
@ -7067,10 +7067,11 @@ impl Bank {
|
|||
Arc::from(stakes.vote_accounts())
|
||||
}
|
||||
|
||||
/// Vote account for the given vote account pubkey along with the stake.
|
||||
pub fn get_vote_account(&self, vote_account: &Pubkey) -> Option<(/*stake:*/ u64, VoteAccount)> {
|
||||
/// Vote account for the given vote account pubkey.
|
||||
pub fn get_vote_account(&self, vote_account: &Pubkey) -> Option<VoteAccount> {
|
||||
let stakes = self.stakes_cache.stakes();
|
||||
stakes.vote_accounts().get(vote_account).cloned()
|
||||
let (_stake, ref vote_account) = stakes.vote_accounts().get(vote_account)?;
|
||||
Some(vote_account.clone())
|
||||
}
|
||||
|
||||
/// Get the EpochStakes for a given epoch
|
||||
|
|
Loading…
Reference in New Issue