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