check freeze before updating slot_hashes (#4448)

* check freeze before updating slot_hashes

* fixup
This commit is contained in:
Rob Walker 2019-05-28 12:25:55 -07:00 committed by GitHub
parent ff31ffbd54
commit 441fed7a5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -215,18 +215,22 @@ impl Bank {
self.store(&slot_hashes::id(), &account); self.store(&slot_hashes::id(), &account);
} }
fn set_hash(&self) { fn set_hash(&self) -> bool {
let mut hash = self.hash.write().unwrap(); let mut hash = self.hash.write().unwrap();
if *hash == Hash::default() { if *hash == Hash::default() {
// freeze is a one-way trip, idempotent // freeze is a one-way trip, idempotent
*hash = self.hash_internal_state(); *hash = self.hash_internal_state();
true
} else {
false
} }
} }
pub fn freeze(&self) { pub fn freeze(&self) {
self.set_hash(); if self.set_hash() {
self.update_slot_hashes(); self.update_slot_hashes();
}
} }
pub fn epoch_schedule(&self) -> &EpochSchedule { pub fn epoch_schedule(&self) -> &EpochSchedule {