Struct cuprate_pruning::DecompressedPruningSeed

source ·
pub struct DecompressedPruningSeed { /* private fields */ }
Expand description

This represents a valid Monero pruning seed.

It does allow representations of pruning seeds that Monero’s P2P network would not allow, i.e. it does not restrict the seed to only have a log_stripes of 8.

Implementations§

source§

impl DecompressedPruningSeed

source

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

Creates a new pruning seed from a stripe and log_stripes

§What is a stripe

A stripe is the part of the blockchain this peer will keep.

Monero, when pruning, will split the blockchain into multiple “stripes”, that amount is currently 8 and each pruned peer will keep one of those 8 stripes.

§What is log_stripes

log_stripes is log2 of the amount of stripes used.

For Monero, currently, that amount is 8 so log_stripes will be 3.


note this function allows you to make invalid seeds, this is done to allow the specifics of pruning to change in the future. To make a valid seed you currently MUST pass in a number 1 to 8 for stripe and 3 for log_stripes.

source

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

Attempts to decompress a raw pruning seed.

Will return Ok(None) if the pruning seed means no pruning.

An error means the pruning seed was invalid.

source

pub const fn compress(&self) -> u32

Compresses the pruning seed into a u32.

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_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

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.

§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 DecompressedPruningSeed

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 DecompressedPruningSeed

source§

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

source§

impl Clone for DecompressedPruningSeed

source§

fn clone(&self) -> DecompressedPruningSeed

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 DecompressedPruningSeed

source§

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

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

impl Hash for DecompressedPruningSeed

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 DecompressedPruningSeed

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 DecompressedPruningSeed

source§

fn eq(&self, other: &DecompressedPruningSeed) -> 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 DecompressedPruningSeed

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 DecompressedPruningSeed

source§

impl Eq for DecompressedPruningSeed

source§

impl StructuralPartialEq for DecompressedPruningSeed

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: 8 bytes