Skip to content

Commit

Permalink
Recompute hash on load if default hash is stored for the account (sol…
Browse files Browse the repository at this point in the history
…ana-labs#519)

recompute hash on load if default hash is stored for the account

Co-authored-by: HaoranYi <[email protected]>
  • Loading branch information
HaoranYi and HaoranYi authored Apr 2, 2024
1 parent 9f8a478 commit 9ea627c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7607,7 +7607,10 @@ impl AccountsDb {
Some((*loaded_account.pubkey(), loaded_account.loaded_hash()))
},
|accum: &DashMap<Pubkey, AccountHash>, loaded_account: LoadedAccount| {
let loaded_hash = loaded_account.loaded_hash();
let mut loaded_hash = loaded_account.loaded_hash();
if loaded_hash == AccountHash(Hash::default()) {
loaded_hash = Self::hash_account(&loaded_account, loaded_account.pubkey())
}
accum.insert(*loaded_account.pubkey(), loaded_hash);
},
);
Expand Down Expand Up @@ -7639,9 +7642,13 @@ impl AccountsDb {
|accum: &DashMap<Pubkey, (AccountHash, AccountSharedData)>,
loaded_account: LoadedAccount| {
// Storage may have duplicates so only keep the latest version for each key
let mut loaded_hash = loaded_account.loaded_hash();
if loaded_hash == AccountHash(Hash::default()) {
loaded_hash = Self::hash_account(&loaded_account, loaded_account.pubkey())
}
accum.insert(
*loaded_account.pubkey(),
(loaded_account.loaded_hash(), loaded_account.take_account()),
(loaded_hash, loaded_account.take_account()),
);
},
);
Expand Down

0 comments on commit 9ea627c

Please sign in to comment.