hash_account_with_rent_epoch (#24104)
This commit is contained in:
parent
ba92ba0e06
commit
4a11fa072f
|
@ -4402,6 +4402,23 @@ impl AccountsDb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn hash_account_with_rent_epoch<T: ReadableAccount>(
|
||||||
|
slot: Slot,
|
||||||
|
account: &T,
|
||||||
|
pubkey: &Pubkey,
|
||||||
|
rent_epoch: Epoch,
|
||||||
|
) -> Hash {
|
||||||
|
Self::hash_account_data(
|
||||||
|
slot,
|
||||||
|
account.lamports(),
|
||||||
|
account.owner(),
|
||||||
|
account.executable(),
|
||||||
|
rent_epoch,
|
||||||
|
account.data(),
|
||||||
|
pubkey,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn hash_account<T: ReadableAccount>(slot: Slot, account: &T, pubkey: &Pubkey) -> Hash {
|
pub fn hash_account<T: ReadableAccount>(slot: Slot, account: &T, pubkey: &Pubkey) -> Hash {
|
||||||
Self::hash_account_data(
|
Self::hash_account_data(
|
||||||
slot,
|
slot,
|
||||||
|
@ -13742,4 +13759,19 @@ pub mod tests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hash_account_with_rent_epoch() {
|
||||||
|
let owner = solana_sdk::pubkey::new_rand();
|
||||||
|
let pubkey = solana_sdk::pubkey::new_rand();
|
||||||
|
let slot = 9;
|
||||||
|
let mut account = AccountSharedData::new(2, 1, &owner);
|
||||||
|
for rent in 0..3 {
|
||||||
|
account.set_rent_epoch(rent);
|
||||||
|
assert_eq!(
|
||||||
|
AccountsDb::hash_account(slot, &account, &pubkey),
|
||||||
|
AccountsDb::hash_account_with_rent_epoch(slot, &account, &pubkey, rent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue