From 84a741d0f9ba09bff6a409c077ebacdc531fd561 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 10 Mar 2016 00:21:07 +0100 Subject: [PATCH] Don't call mark_as_bad needlessly --- ethcore/src/block_queue.rs | 6 ++++++ ethcore/src/client.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ethcore/src/block_queue.rs b/ethcore/src/block_queue.rs index 8f1105b8b..c83542f12 100644 --- a/ethcore/src/block_queue.rs +++ b/ethcore/src/block_queue.rs @@ -320,6 +320,9 @@ impl BlockQueue { /// Mark given block and all its children as bad. Stops verification. pub fn mark_as_bad(&mut self, block_hashes: &[H256]) { + if block_hashes.is_empty() { + return; + } let mut verification_lock = self.verification.lock().unwrap(); let mut processing = self.processing.write().unwrap(); @@ -345,6 +348,9 @@ impl BlockQueue { /// Mark given block as processed pub fn mark_as_good(&mut self, block_hashes: &[H256]) { + if block_hashes.is_empty() { + return; + } let mut processing = self.processing.write().unwrap(); for hash in block_hashes { processing.remove(&hash); diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 8471666aa..2d9b2e3c5 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -404,8 +404,12 @@ impl Client where V: Verifier { { let mut block_queue = self.block_queue.write().unwrap(); - block_queue.mark_as_bad(&bad_blocks); - block_queue.mark_as_good(&good_blocks); + if !bad_blocks.is_empty() { + block_queue.mark_as_bad(&bad_blocks); + } + if !good_blocks.is_empty() { + block_queue.mark_as_good(&good_blocks); + } } {