Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
include in purge, versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jbiseda committed May 20, 2022
1 parent f2fe1dd commit 6116e88
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ledger/src/blockstore/blockstore_purge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ impl Blockstore {
& self
.db
.delete_range_cf::<cf::BlockHeight>(&mut write_batch, from_slot, to_slot)
.is_ok()
& self
.db
.delete_range_cf::<cf::OptimisticSlots>(&mut write_batch, from_slot, to_slot)
.is_ok();
let mut w_active_transaction_status_index =
self.active_transaction_status_index.write().unwrap();
Expand Down Expand Up @@ -328,6 +332,10 @@ impl Blockstore {
&& self
.block_height_cf
.compact_range(from_slot, to_slot)
.unwrap_or(false)
&& self
.optimistic_slots_cf
.compact_range(from_slot, to_slot)
.unwrap_or(false);
compact_timer.stop();
if !result {
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ impl ColumnName for columns::OptimisticSlots {
const NAME: &'static str = OPTIMISTIC_SLOTS_CF;
}
impl TypedColumn for columns::OptimisticSlots {
type Type = blockstore_meta::OptimisticSlotMeta;
type Type = blockstore_meta::OptimisticSlotMetaVersioned;
}

#[derive(Debug)]
Expand Down
24 changes: 23 additions & 1 deletion ledger/src/blockstore_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,33 @@ pub struct ProgramCost {
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
pub struct OptimisticSlotMeta {
pub struct OptimisticSlotMetaV0 {
pub hash: Hash,
pub timestamp: UnixTimestamp,
}

#[derive(Deserialize, Serialize, Debug, PartialEq)]
pub enum OptimisticSlotMetaVersioned {
V0(OptimisticSlotMetaV0),
}

impl OptimisticSlotMetaVersioned {
pub fn new(hash: Hash, timestamp: UnixTimestamp) -> Self {
OptimisticSlotMetaVersioned::V0(OptimisticSlotMetaV0 { hash, timestamp })
}

pub fn hash(&self) -> Hash {
match self {
OptimisticSlotMetaVersioned::V0(meta) => meta.hash,
}
}

pub fn timestamp(&self) -> UnixTimestamp {
match self {
OptimisticSlotMetaVersioned::V0(meta) => meta.timestamp,
}
}
}
#[cfg(test)]
mod test {
use {
Expand Down

0 comments on commit 6116e88

Please sign in to comment.