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
impl PruningSeed
Sourcepub fn new_pruned(stripe: u32, log_stripes: u32) -> Result<Self, PruningError>
pub fn new_pruned(stripe: u32, log_stripes: u32) -> Result<Self, PruningError>
Creates a new PruningSeed::Pruned
seed.
Sourcepub fn decompress(seed: u32) -> Result<Self, PruningError>
pub fn decompress(seed: u32) -> Result<Self, PruningError>
Attempts to decompress a raw pruning seed.
An error means the pruning seed was invalid.
Sourcepub fn decompress_p2p_rules(seed: u32) -> Result<Self, PruningError>
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.
Sourcepub const fn get_log_stripes(&self) -> Option<u32>
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.
Sourcepub const fn get_stripe(&self) -> Option<u32>
pub const fn get_stripe(&self) -> Option<u32>
Returns the stripe
for this seed, if this seed is pruned otherwise None
is returned.
Sourcepub const fn has_full_block(
&self,
height: usize,
blockchain_height: usize,
) -> bool
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.
Sourcepub fn get_next_pruned_block(
&self,
block_height: usize,
blockchain_height: usize,
) -> Result<Option<usize>, PruningError>
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 MAX_BLOCK_HEIGHT_USIZE
.
This function will also error if block_height
> blockchain_height
Sourcepub fn get_next_unpruned_block(
&self,
block_height: usize,
blockchain_height: usize,
) -> Result<usize, PruningError>
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 MAX_BLOCK_HEIGHT_USIZE
.
This function will also error if block_height
> blockchain_height
Trait Implementations§
Source§impl BorshDeserialize for PruningSeed
impl BorshDeserialize for PruningSeed
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for PruningSeed
impl BorshSerialize for PruningSeed
Source§impl Clone for PruningSeed
impl Clone for PruningSeed
Source§fn clone(&self) -> PruningSeed
fn clone(&self) -> PruningSeed
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PruningSeed
impl Debug for PruningSeed
Source§impl EnumExt for PruningSeed
impl EnumExt for PruningSeed
Source§impl Hash for PruningSeed
impl Hash for PruningSeed
Source§impl Ord for PruningSeed
impl Ord for PruningSeed
Source§impl PartialEq for PruningSeed
impl PartialEq for PruningSeed
Source§impl PartialOrd for PruningSeed
impl PartialOrd for PruningSeed
impl Copy for PruningSeed
impl Eq for PruningSeed
impl StructuralPartialEq for PruningSeed
Auto Trait Implementations§
impl Freeze for PruningSeed
impl RefUnwindSafe for PruningSeed
impl Send for PruningSeed
impl Sync for PruningSeed
impl Unpin for PruningSeed
impl UnwindSafe for PruningSeed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 bytesPruned
: 8 bytes