diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 0342a323905876..9df20b68868329 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -3864,6 +3864,8 @@ impl Blockstore { with_hash: bool, ) -> Result<()> { self.set_roots(slots.iter().map(|(slot, _hash)| slot))?; + // Remove any old duplicate proofs + self.remove_slot_duplicate_proofs(slots.iter().map(|(slot, _hash)| *slot))?; if with_hash { self.set_duplicate_confirmed_slots_and_hashes( slots @@ -3895,6 +3897,20 @@ impl Blockstore { self.duplicate_slots_cf.delete(slot) } + fn remove_slot_duplicate_proofs(&self, slots: I) -> Result<()> + where + I: Iterator, + { + let mut write_batch = self.db.batch()?; + + for slot in slots { + write_batch.delete::(slot)?; + } + + self.db.write(write_batch)?; + Ok(()) + } + pub fn get_first_duplicate_proof(&self) -> Option<(Slot, DuplicateSlotProof)> { let mut iter = self .db