Skip to content

Commit

Permalink
blockstore: remove old duplicate proofs for rooted slots at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Jul 2, 2024
1 parent 1d9d6fd commit bd251c9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3895,6 +3897,20 @@ impl Blockstore {
self.duplicate_slots_cf.delete(slot)
}

fn remove_slot_duplicate_proofs<I>(&self, slots: I) -> Result<()>
where
I: Iterator<Item = Slot>,
{
let mut write_batch = self.db.batch()?;

for slot in slots {
write_batch.delete::<cf::DuplicateSlots>(slot)?;
}

self.db.write(write_batch)?;
Ok(())
}

pub fn get_first_duplicate_proof(&self) -> Option<(Slot, DuplicateSlotProof)> {
let mut iter = self
.db
Expand Down

0 comments on commit bd251c9

Please sign in to comment.