Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #648 from ethcore/bq-fix
Browse files Browse the repository at this point in the history
Don't call mark_as_bad needlessly
  • Loading branch information
tomusdrw committed Mar 10, 2016
2 parents 2ecad23 + 84a741d commit c380380
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ethcore/src/block_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions ethcore/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,12 @@ impl<V> Client<V> 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);
}
}

{
Expand Down

0 comments on commit c380380

Please sign in to comment.