Renames fn to insert_default_bank_hash() (#28929)
This commit is contained in:
parent
5d88a9b32b
commit
40a7c6d46a
|
@ -218,7 +218,7 @@ impl Accounts {
|
||||||
|
|
||||||
pub fn new_from_parent(parent: &Accounts, slot: Slot, parent_slot: Slot) -> Self {
|
pub fn new_from_parent(parent: &Accounts, slot: Slot, parent_slot: Slot) -> Self {
|
||||||
let accounts_db = parent.accounts_db.clone();
|
let accounts_db = parent.accounts_db.clone();
|
||||||
accounts_db.set_hash(slot, parent_slot);
|
accounts_db.insert_default_bank_hash(slot, parent_slot);
|
||||||
Self {
|
Self {
|
||||||
accounts_db,
|
accounts_db,
|
||||||
account_locks: Mutex::new(AccountLocks::default()),
|
account_locks: Mutex::new(AccountLocks::default()),
|
||||||
|
|
|
@ -4971,7 +4971,11 @@ impl AccountsDb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_hash(&self, slot: Slot, parent_slot: Slot) {
|
/// Insert a new bank hash for `slot`
|
||||||
|
///
|
||||||
|
/// The new bank hash is empty/default except for the slot. This fn is called when creating a
|
||||||
|
/// new bank from parent. The bank hash for this slot is updated with real values later.
|
||||||
|
pub fn insert_default_bank_hash(&self, slot: Slot, parent_slot: Slot) {
|
||||||
let mut bank_hashes = self.bank_hashes.write().unwrap();
|
let mut bank_hashes = self.bank_hashes.write().unwrap();
|
||||||
if bank_hashes.get(&slot).is_some() {
|
if bank_hashes.get(&slot).is_some() {
|
||||||
error!(
|
error!(
|
||||||
|
@ -12323,12 +12327,12 @@ pub mod tests {
|
||||||
accounts.add_root(0);
|
accounts.add_root(0);
|
||||||
|
|
||||||
let mut current_slot = 1;
|
let mut current_slot = 1;
|
||||||
accounts.set_hash(current_slot, current_slot - 1);
|
accounts.insert_default_bank_hash(current_slot, current_slot - 1);
|
||||||
accounts.store_uncached(current_slot, &[(&pubkey, &account)]);
|
accounts.store_uncached(current_slot, &[(&pubkey, &account)]);
|
||||||
accounts.add_root(current_slot);
|
accounts.add_root(current_slot);
|
||||||
|
|
||||||
current_slot += 1;
|
current_slot += 1;
|
||||||
accounts.set_hash(current_slot, current_slot - 1);
|
accounts.insert_default_bank_hash(current_slot, current_slot - 1);
|
||||||
accounts.store_uncached(current_slot, &[(&pubkey, &zero_lamport_account)]);
|
accounts.store_uncached(current_slot, &[(&pubkey, &zero_lamport_account)]);
|
||||||
accounts.add_root(current_slot);
|
accounts.add_root(current_slot);
|
||||||
|
|
||||||
|
@ -12336,7 +12340,7 @@ pub mod tests {
|
||||||
|
|
||||||
// Otherwise slot 2 will not be removed
|
// Otherwise slot 2 will not be removed
|
||||||
current_slot += 1;
|
current_slot += 1;
|
||||||
accounts.set_hash(current_slot, current_slot - 1);
|
accounts.insert_default_bank_hash(current_slot, current_slot - 1);
|
||||||
accounts.add_root(current_slot);
|
accounts.add_root(current_slot);
|
||||||
|
|
||||||
accounts.print_accounts_stats("pre_purge");
|
accounts.print_accounts_stats("pre_purge");
|
||||||
|
|
Loading…
Reference in New Issue