Merge pull request #39 from paritytech/bkchr-safety-violation

Don't finalize the same block multiple times
This commit is contained in:
Bastian Köcher
2020-01-16 08:43:53 +01:00
committed by GitHub
+11 -6
View File
@@ -131,12 +131,17 @@ where
type Block = Block;
fn finalize(&self, hash: <Self::Block as BlockT>::Hash) -> ClientResult<bool> {
match self.finalize_block(BlockId::hash(hash), None, true) {
Ok(()) => Ok(true),
Err(e) => match e {
ClientError::UnknownBlock(_) => Ok(false),
_ => Err(e),
},
// don't finalize the same block multiple times.
if self.chain_info().finalized_hash != hash {
match self.finalize_block(BlockId::hash(hash), None, true) {
Ok(()) => Ok(true),
Err(e) => match e {
ClientError::UnknownBlock(_) => Ok(false),
_ => Err(e),
},
}
} else {
Ok(true)
}
}
}