From 839ef1f6fe35c7ac38056a611ec7f06235f26c68 Mon Sep 17 00:00:00 2001 From: vedhavyas Date: Thu, 15 Jun 2023 10:17:11 +0530 Subject: [PATCH] track only unique block hashes when writing to DB 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 --- client/db/src/kv/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/client/db/src/kv/mod.rs b/client/db/src/kv/mod.rs index 74d3c10ed3..03b00f01c0 100644 --- a/client/db/src/kv/mod.rs +++ b/client/db/src/kv/mod.rs @@ -308,13 +308,15 @@ impl MappingDb { 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],