cleanup in vote/stake accounts (#24608)

* cleanup in vote/stake accounts

* reorder comparisons in accounts_equal
This commit is contained in:
Jeff Washington (jwash) 2022-04-23 08:28:21 -05:00 committed by GitHub
parent 06f7c69caf
commit 14ee36a2af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 16 deletions

View File

@ -13,7 +13,7 @@ use {
};
/// An account and a stake state deserialized from the account.
/// Generic type T enforces type-saftey so that StakeAccount<Delegation> can
/// Generic type T enforces type-safety so that StakeAccount<Delegation> can
/// only wrap a stake-state which is a Delegation; whereas StakeAccount<()>
/// wraps any account with stake state.
#[derive(Clone, Debug, Default)]

View File

@ -5,7 +5,7 @@ use {
ser::{Serialize, Serializer},
},
solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount},
account::{accounts_equal, Account, AccountSharedData, ReadableAccount},
instruction::InstructionError,
pubkey::Pubkey,
},
@ -244,18 +244,7 @@ impl PartialEq<VoteAccountInner> for VoteAccountInner {
impl PartialEq<AccountSharedData> for VoteAccount {
fn eq(&self, other: &AccountSharedData) -> bool {
let Account {
lamports,
data,
owner,
executable,
rent_epoch,
} = &self.0.account;
other.lamports() == *lamports
&& other.executable() == *executable
&& other.rent_epoch() == *rent_epoch
&& other.owner() == owner
&& other.data() == data
accounts_equal(&self.0.account, other)
}
}

View File

@ -113,10 +113,10 @@ pub struct AccountSharedData {
/// Returns true if accounts are essentially equivalent as in all fields are equivalent.
pub fn accounts_equal<T: ReadableAccount, U: ReadableAccount>(me: &T, other: &U) -> bool {
me.lamports() == other.lamports()
&& me.data() == other.data()
&& me.owner() == other.owner()
&& me.executable() == other.executable()
&& me.rent_epoch() == other.rent_epoch()
&& me.owner() == other.owner()
&& me.data() == other.data()
}
impl From<AccountSharedData> for Account {