Pruner

Struct Pruner 

Source
pub struct Pruner {
    policy: PruningPolicy,
    preserved: HashSet<Hash>,
    stable_frontier: Option<VersionVector>,
}
Expand description

Pruner for removing old DAG nodes.

Fields§

§policy: PruningPolicy

Pruning policy.

§preserved: HashSet<Hash>

Set of CIDs that must be preserved (e.g., recent snapshots).

§stable_frontier: Option<VersionVector>

The stable frontier at the time of pruning.

Implementations§

Source§

impl Pruner

Source

pub fn new() -> Self

Create a new pruner with default policy.

Source

pub fn with_policy(policy: PruningPolicy) -> Self

Create a pruner with custom policy.

Source

pub fn policy(&self) -> &PruningPolicy

Get the current policy.

Source

pub fn set_stable_frontier(&mut self, frontier: VersionVector)

Set the stable frontier for pruning decisions.

Source

pub fn preserve(&mut self, cid: Hash)

Mark a CID as preserved (cannot be pruned).

Source

pub fn clear_preserved(&mut self)

Clear preserved CIDs.

Source

pub fn identify_prunable<S: DAGStore>( &self, store: &S, snapshot: &Snapshot, current_time: u64, ) -> Vec<Hash>

Identify nodes that can be safely pruned.

This doesn’t actually modify the store - it returns the list of nodes that would be pruned if execute_prune is called.

Source

pub fn execute_prune<S: DAGStore + PrunableStore>( &self, store: &mut S, snapshot: &Snapshot, current_time: u64, ) -> PruningResult

Execute pruning on a mutable store.

Returns the result of the pruning operation.

Source

pub fn should_prune<S: DAGStore>( &self, store: &S, snapshot: &Snapshot, stability_monitor: Option<&StabilityMonitor>, ) -> bool

Check if pruning should be performed.

Source

fn ancestors_within_depth<S: DAGStore>( &self, store: &S, cid: &Hash, depth: usize, ) -> HashSet<Hash>

Get ancestors within a certain depth.

Source

fn find_genesis_path<S: DAGStore>(&self, store: &S) -> Option<Vec<Hash>>

Find a path from any head to genesis.

Trait Implementations§

Source§

impl Default for Pruner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Pruner

§

impl RefUnwindSafe for Pruner

§

impl Send for Pruner

§

impl Sync for Pruner

§

impl Unpin for Pruner

§

impl UnwindSafe for Pruner

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.