From 9aada0b07f33f8221d4c4c45eb0224eaadd2671c Mon Sep 17 00:00:00 2001 From: who-biz <37732338+who-biz@users.noreply.github.com> Date: Tue, 26 Sep 2023 22:43:44 +0000 Subject: [PATCH] Don't use mut vars in OrphanBlockPool::clear, set evicted=0 --- chain/src/chain.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/chain/src/chain.rs b/chain/src/chain.rs index fd381bc7..598ff691 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -135,11 +135,10 @@ impl OrphanBlockPool { } pub fn clear(&self) -> bool { - let mut orphans = self.orphans.write(); - let mut height_idx = self.height_idx.write(); - orphans.clear(); - height_idx.clear(); - return orphans.is_empty() && height_idx.is_empty(); + self.orphans.write().clear(); + self.height_idx.write().clear(); + self.evicted.store(0, Ordering::Relaxed); + return self.orphans.read().is_empty() && self.height_idx.read().is_empty(); } pub fn contains(&self, hash: &Hash) -> bool { @@ -525,7 +524,7 @@ impl Chain { orphans_result } - /// Clear OprhanBlockPool completely, returns true if orphans list + /// Clear OrphanBlockPool completely, returns true if orphans list /// and height_idx are empty after clearing, false if failed pub fn clear_orphans(&self) -> bool { self.orphans.clear()