Remove hash field from account (#9915)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::{clock::Epoch, hash::Hash, instruction::InstructionError, pubkey::Pubkey};
|
||||
use crate::{clock::Epoch, instruction::InstructionError, pubkey::Pubkey};
|
||||
use std::{
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
cmp, fmt,
|
||||
@ -8,7 +8,7 @@ use std::{
|
||||
|
||||
/// An Account with data that is stored on chain
|
||||
#[repr(C)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Account {
|
||||
/// lamports in the account
|
||||
@ -22,26 +22,8 @@ pub struct Account {
|
||||
pub executable: bool,
|
||||
/// the epoch at which this account will next owe rent
|
||||
pub rent_epoch: Epoch,
|
||||
/// Hash of this account's state, skip serializing as to not expose to external api
|
||||
/// Used for keeping the accounts state hash updated.
|
||||
#[serde(skip)]
|
||||
pub hash: Hash,
|
||||
}
|
||||
|
||||
/// skip comparison of account.hash, since it is only meaningful when the account is loaded in a
|
||||
/// given fork and some tests do not have that.
|
||||
impl PartialEq for Account {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.lamports == other.lamports
|
||||
&& self.data == other.data
|
||||
&& self.owner == other.owner
|
||||
&& self.executable == other.executable
|
||||
&& self.rent_epoch == other.rent_epoch
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Account {}
|
||||
|
||||
impl fmt::Debug for Account {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let data_len = cmp::min(64, self.data.len());
|
||||
@ -52,14 +34,13 @@ impl fmt::Debug for Account {
|
||||
};
|
||||
write!(
|
||||
f,
|
||||
"Account {{ lamports: {} data.len: {} owner: {} executable: {} rent_epoch: {}{} hash: {} }}",
|
||||
"Account {{ lamports: {} data.len: {} owner: {} executable: {} rent_epoch: {}{} }}",
|
||||
self.lamports,
|
||||
self.data.len(),
|
||||
self.owner,
|
||||
self.executable,
|
||||
self.rent_epoch,
|
||||
data_str,
|
||||
self.hash,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{account::Account, hash::Hash};
|
||||
use crate::account::Account;
|
||||
|
||||
crate::declare_id!("NativeLoader1111111111111111111111111111111");
|
||||
|
||||
@ -10,6 +10,5 @@ pub fn create_loadable_account(name: &str) -> Account {
|
||||
data: name.as_bytes().to_vec(),
|
||||
executable: true,
|
||||
rent_epoch: 0,
|
||||
hash: Hash::default(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user