Skip to content

Commit

Permalink
track only unique block hashes when writing to DB (#1087)
Browse files Browse the repository at this point in the history
Seems like import notifications is sending the block hash multiple times and everytime its called, even the same hash gets written to DB event though the DB has already seen it. This change should ensure we only write unique fork hashes
  • Loading branch information
vedhavyas authored Jun 23, 2023
1 parent 4cde307 commit 036e6af
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions client/db/src/kv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,15 @@ impl<Block: BlockT> MappingDb<Block> {

let substrate_hashes = match self.block_hash(&commitment.ethereum_block_hash) {
Ok(Some(mut data)) => {
data.push(commitment.block_hash);
log::warn!(
target: "fc-db",
"Possible equivocation at ethereum block hash {} {:?}",
&commitment.ethereum_block_hash,
&data
);
if !data.contains(&commitment.block_hash) {
data.push(commitment.block_hash);
log::warn!(
target: "fc-db",
"Possible equivocation at ethereum block hash {} {:?}",
&commitment.ethereum_block_hash,
&data
);
}
data
}
_ => vec![commitment.block_hash],
Expand Down

0 comments on commit 036e6af

Please sign in to comment.