Fixing mark_as_bad implementation

This commit is contained in:
Tomasz Drwięga 2016-02-24 17:01:29 +01:00
parent d914a27bdf
commit 08647282df
2 changed files with 15 additions and 12 deletions

@ -1 +1 @@
Subproject commit f32954b3ddb5af2dc3dc9ec6d9a28bee848fdf70
Subproject commit 3116f85a499ceaf4dfdc46726060fc056e2d7829

View File

@ -287,20 +287,23 @@ impl BlockQueue {
/// Mark given block and all its children as bad. Stops verification.
pub fn mark_as_bad(&mut self, hashes: &[H256]) {
let mut verification_lock = self.verification.lock().unwrap();
let mut verification = verification_lock.deref_mut();
let mut new_verified = VecDeque::new();
let mut processing = self.processing.write().unwrap();
let mut verification = verification_lock.deref_mut();
verification.bad.reserve(hashes.len());
for hash in hashes {
verification.bad.insert(hash.clone());
self.processing.write().unwrap().remove(&hash);
for block in verification.verified.drain(..) {
if verification.bad.contains(&block.header.parent_hash) {
verification.bad.insert(block.header.hash());
self.processing.write().unwrap().remove(&block.header.hash());
}
else {
new_verified.push_back(block);
}
processing.remove(&hash);
}
let mut new_verified = VecDeque::new();
for block in verification.verified.drain(..) {
if verification.bad.contains(&block.header.parent_hash) {
verification.bad.insert(block.header.hash());
processing.remove(&block.header.hash());
} else {
new_verified.push_back(block);
}
}
verification.verified = new_verified;