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

Commit 6a04f4d

Browse files
authored
Merge pull request #39 from paritytech/bkchr-safety-violation
Don't finalize the same block multiple times
2 parents dcde10c + f0baba9 commit 6a04f4d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

consensus/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,17 @@ where
131131
type Block = Block;
132132

133133
fn finalize(&self, hash: <Self::Block as BlockT>::Hash) -> ClientResult<bool> {
134-
match self.finalize_block(BlockId::hash(hash), None, true) {
135-
Ok(()) => Ok(true),
136-
Err(e) => match e {
137-
ClientError::UnknownBlock(_) => Ok(false),
138-
_ => Err(e),
139-
},
134+
// don't finalize the same block multiple times.
135+
if self.chain_info().finalized_hash != hash {
136+
match self.finalize_block(BlockId::hash(hash), None, true) {
137+
Ok(()) => Ok(true),
138+
Err(e) => match e {
139+
ClientError::UnknownBlock(_) => Ok(false),
140+
_ => Err(e),
141+
},
142+
}
143+
} else {
144+
Ok(true)
140145
}
141146
}
142147
}

0 commit comments

Comments
 (0)