Enum cuprate_pruning::PruningSeed

source ·
pub enum PruningSeed {
    NotPruned,
    Pruned(DecompressedPruningSeed),
}
Expand description

A valid pruning seed for a Monero node.

A pruning seed tells nodes which blocks they should keep and which they should prune.

Variants§

§

NotPruned

A peer with this seed is not pruned.

§

Pruned(DecompressedPruningSeed)

A peer with this seed is pruned.

Implementations§

source§

impl PruningSeed

source

pub fn new_pruned(stripe: u32, log_stripes: u32) -> Result<Self, PruningError>

source

pub fn decompress(seed: u32) -> Result<Self, PruningError>

Attempts to decompress a raw pruning seed.

An error means the pruning seed was invalid.

source

pub fn decompress_p2p_rules(seed: u32) -> Result<Self, PruningError>

Decompresses the seed, performing the same checks as PruningSeed::decompress and some more according to Monero’s p2p networks rules.

The only added check currently is that log_stripes == 3.

source

pub const fn compress(&self) -> u32

Compresses this pruning seed to a u32.

source

pub const fn get_log_stripes(&self) -> Option<u32>

Returns the log_stripes for this seed, if this seed is pruned otherwise None is returned.

source

pub const fn get_stripe(&self) -> Option<u32>

Returns the stripe for this seed, if this seed is pruned otherwise None is returned.

source

pub const fn has_full_block( &self, height: usize, blockchain_height: usize, ) -> bool

Returns true if a peer with this pruning seed should have a non-pruned version of a block.

source

pub fn get_next_pruned_block( &self, block_height: usize, blockchain_height: usize, ) -> Result<Option<usize>, PruningError>

Gets the next pruned block for a given block_height and blockchain_height

Each seed will store, in a cyclic manner, a portion of blocks while discarding the ones that are out of your stripe. This function is finding the next height for which a specific seed will start pruning blocks.

This will return Ok(None) if the seed does no pruning or if there is no pruned block after this one.

§Errors

This function will return an Error if the inputted block_height or blockchain_height is greater than CRYPTONOTE_MAX_BLOCK_HEIGHT.

This function will also error if block_height > blockchain_height

source

pub fn get_next_unpruned_block( &self, block_height: usize, blockchain_height: usize, ) -> Result<usize, PruningError>

Gets the next unpruned block for a given block_height and blockchain_height

Each seed will store, in a cyclic manner, a portion of blocks while discarding the ones that are out of your stripe. This function is finding the next height for which a specific seed will start storing blocks.

§Errors

This function will return an Error if the inputted block_height or blockchain_height is greater than CRYPTONOTE_MAX_BLOCK_HEIGHT.

This function will also error if block_height > blockchain_height

Trait Implementations§

source§

impl BorshDeserialize for PruningSeed

source§

fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>

source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

source§

impl BorshSerialize for PruningSeed

source§

fn serialize<__W: Write>(&self, writer: &mut __W) -> Result<(), Error>

source§

impl Clone for PruningSeed

source§

fn clone(&self) -> PruningSeed

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PruningSeed

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl EnumExt for PruningSeed

source§

fn deserialize_variant<__R: Read>( reader: &mut __R, variant_tag: u8, ) -> Result<Self, Error>

Deserialises given variant of an enum from the reader. Read more
source§

impl Hash for PruningSeed

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for PruningSeed

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for PruningSeed

source§

fn eq(&self, other: &PruningSeed) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for PruningSeed

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for PruningSeed

source§

impl Eq for PruningSeed

source§

impl StructuralPartialEq for PruningSeed

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 12 bytes

Size for each variant:

  • NotPruned: 0 bytes
  • Pruned: 8 bytes