From 441fed7a5bc0ebb3ef16eece71d08794a41b1620 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Tue, 28 May 2019 12:25:55 -0700 Subject: [PATCH] check freeze before updating slot_hashes (#4448) * check freeze before updating slot_hashes * fixup --- runtime/src/bank.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 0f1a963f5d..9021555063 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -215,18 +215,22 @@ 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(); - self.update_slot_hashes(); + if self.set_hash() { + self.update_slot_hashes(); + } } pub fn epoch_schedule(&self) -> &EpochSchedule {