diff --git a/lib/modules/blockchain/bc-db-writer/src/blocks.rs b/lib/modules/blockchain/bc-db-writer/src/blocks.rs index 0cb83ff060fcf40300b0ef0ace5a58b817733e94..727e05c7f643cff64a7ace69b09ef1e6b6a57b8a 100644 --- a/lib/modules/blockchain/bc-db-writer/src/blocks.rs +++ b/lib/modules/blockchain/bc-db-writer/src/blocks.rs @@ -78,7 +78,12 @@ pub fn insert_new_head_block( // Remove too old blocks for blockstamp in removed_blockstamps { let blockstamp_bytes: Vec<u8> = blockstamp.into(); - fork_blocks_store.delete(w.as_mut(), &blockstamp_bytes)?; + if fork_blocks_store + .get(w.as_ref(), &blockstamp_bytes)? + .is_some() + { + fork_blocks_store.delete(w.as_mut(), &blockstamp_bytes)?; + } } } Ok(()) diff --git a/lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs b/lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs index 019eefa3642dac2c5f65d106de0c4528d10176e9..174eb82285016341216953ee71f1d186ce19bd19 100644 --- a/lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs +++ b/lib/modules/blockchain/bc-db-writer/src/blocks/fork_tree.rs @@ -87,7 +87,12 @@ pub fn change_main_branch( let fork_blocks_store = db.get_store(FORK_BLOCKS); for blockstamp in removed_blockstamps { let blockstamp_bytes: Vec<u8> = blockstamp.into(); - fork_blocks_store.delete(w.as_mut(), &blockstamp_bytes)?; + if fork_blocks_store + .get(w.as_ref(), &blockstamp_bytes)? + .is_some() + { + fork_blocks_store.delete(w.as_mut(), &blockstamp_bytes)?; + } } Ok(()) }