optimize get_accounts_delta_hash (#21027)

This commit is contained in:
Jeff Washington (jwash)
2021-10-28 10:40:32 -05:00
committed by GitHub
parent e9ab214237
commit 7a41b2c5d1

View File

@ -5828,16 +5828,8 @@ impl AccountsDb {
if self.is_filler_account(loaded_account.pubkey()) {
return;
}
let should_insert =
if let Some(existing_entry) = accum.get(loaded_account.pubkey()) {
loaded_write_version > existing_entry.value().version()
} else {
true
};
if should_insert {
// Detected insertion is necessary, grabs the write lock to commit the write,
// keep the latest write version for each pubkey
match accum.entry(*loaded_account.pubkey()) {
// Double check in case another thread interleaved a write between the read + write.
Occupied(mut occupied_entry) => {
if loaded_write_version > occupied_entry.get().version() {
occupied_entry.insert((loaded_write_version, loaded_hash));
@ -5848,7 +5840,6 @@ impl AccountsDb {
vacant_entry.insert((loaded_write_version, loaded_hash));
}
}
}
},
);
scan.stop();