From 14ee36a2af0696daaaf62cd4b9f63b5ef7910a39 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Sat, 23 Apr 2022 08:28:21 -0500 Subject: [PATCH] cleanup in vote/stake accounts (#24608) * cleanup in vote/stake accounts * reorder comparisons in accounts_equal --- runtime/src/stake_account.rs | 2 +- runtime/src/vote_account.rs | 15 ++------------- sdk/src/account.rs | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/runtime/src/stake_account.rs b/runtime/src/stake_account.rs index cd9761b289..75f73c4b8c 100644 --- a/runtime/src/stake_account.rs +++ b/runtime/src/stake_account.rs @@ -13,7 +13,7 @@ use { }; /// An account and a stake state deserialized from the account. -/// Generic type T enforces type-saftey so that StakeAccount can +/// Generic type T enforces type-safety so that StakeAccount can /// only wrap a stake-state which is a Delegation; whereas StakeAccount<()> /// wraps any account with stake state. #[derive(Clone, Debug, Default)] diff --git a/runtime/src/vote_account.rs b/runtime/src/vote_account.rs index 3232a4c76e..b7424ea406 100644 --- a/runtime/src/vote_account.rs +++ b/runtime/src/vote_account.rs @@ -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 for VoteAccountInner { impl PartialEq 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) } } diff --git a/sdk/src/account.rs b/sdk/src/account.rs index a480cfa0a6..9ba920cb4e 100644 --- a/sdk/src/account.rs +++ b/sdk/src/account.rs @@ -113,10 +113,10 @@ pub struct AccountSharedData { /// Returns true if accounts are essentially equivalent as in all fields are equivalent. pub fn accounts_equal(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 for Account {