@@ -469,13 +469,14 @@ impl<K: Kind, C> VerificationQueue<K, C> {
|
||||
/// Add a block to the queue.
|
||||
pub fn import(&self, input: K::Input) -> Result<H256, (K::Input, Error)> {
|
||||
let hash = input.hash();
|
||||
let raw_hash = input.raw_hash();
|
||||
{
|
||||
if self.processing.read().contains_key(&hash) {
|
||||
return Err((input, Error::Import(ImportError::AlreadyQueued).into()));
|
||||
}
|
||||
|
||||
let mut bad = self.verification.bad.lock();
|
||||
if bad.contains(&hash) {
|
||||
if bad.contains(&hash) || bad.contains(&raw_hash) {
|
||||
return Err((input, Error::Import(ImportError::KnownBad).into()));
|
||||
}
|
||||
|
||||
@@ -502,6 +503,16 @@ impl<K: Kind, C> VerificationQueue<K, C> {
|
||||
match err {
|
||||
// Don't mark future blocks as bad.
|
||||
Error::Block(BlockError::TemporarilyInvalid(_)) => {},
|
||||
// If the transaction root or uncles hash is invalid, it doesn't necessarily mean
|
||||
// that the header is invalid. We might have just received a malformed block body,
|
||||
// so we shouldn't put the header hash to `bad`.
|
||||
//
|
||||
// We still put the entire `Item` hash to bad, so that we can early reject
|
||||
// the items that are malformed.
|
||||
Error::Block(BlockError::InvalidTransactionsRoot(_)) |
|
||||
Error::Block(BlockError::InvalidUnclesHash(_)) => {
|
||||
self.verification.bad.lock().insert(raw_hash);
|
||||
},
|
||||
_ => {
|
||||
self.verification.bad.lock().insert(hash);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user