Struct grin_core::core::pmmr::segment::Segment

source ·
pub struct Segment<T> { /* private fields */ }
Expand description

Segment of a PMMR: unpruned leaves and the necessary data to verify segment membership in the original MMR.

Implementations§

source§

impl<T> Segment<T>

source

pub fn segment_pos_range(&self, mmr_size: u64) -> (u64, u64)

Inclusive range of MMR positions for this segment

source

pub fn identifier(&self) -> SegmentIdentifier

Get the identifier associated with this segment

source

pub fn parts( self ) -> (SegmentIdentifier, Vec<u64>, Vec<Hash>, Vec<u64>, Vec<T>, SegmentProof)

Consume the segment and return its parts

source

pub fn from_parts( identifier: SegmentIdentifier, hash_pos: Vec<u64>, hashes: Vec<Hash>, leaf_pos: Vec<u64>, leaf_data: Vec<T>, proof: SegmentProof ) -> Self

Construct a segment from its parts

source

pub fn leaf_iter(&self) -> impl Iterator<Item = (u64, &T)> + '_

Iterator of all the leaves in the segment

source

pub fn hash_iter(&self) -> impl Iterator<Item = (u64, Hash)> + '_

Iterator of all the hashes in the segment

source

pub fn proof(&self) -> &SegmentProof

Segment proof

source

pub fn id(&self) -> SegmentIdentifier

Segment identifier

source§

impl<T> Segment<T>
where T: Readable + Writeable + Debug,

source

pub fn from_pmmr<U, B>( segment_id: SegmentIdentifier, pmmr: &ReadonlyPMMR<'_, U, B>, prunable: bool ) -> Result<Self, SegmentError>
where U: PMMRable<E = T>, B: Backend<U>,

Generate a segment from a PMMR

source§

impl<T> Segment<T>

source

pub fn root( &self, mmr_size: u64, bitmap: Option<&Bitmap> ) -> Result<Option<Hash>, SegmentError>

Calculate root hash of this segment Returns None iff the segment is full and completely pruned

source

pub fn first_unpruned_parent( &self, mmr_size: u64, bitmap: Option<&Bitmap> ) -> Result<(Hash, u64), SegmentError>

Get the first 1-based (sucks) unpruned parent hash of this segment

source

pub fn validate( &self, mmr_size: u64, bitmap: Option<&Bitmap>, mmr_root: Hash ) -> Result<(), SegmentError>

Check validity of the segment by calculating its root and validating the merkle proof

source

pub fn validate_with( &self, mmr_size: u64, bitmap: Option<&Bitmap>, mmr_root: Hash, hash_last_pos: u64, other_root: Hash, other_is_left: bool ) -> Result<(), SegmentError>

Check validity of the segment by calculating its root and validating the merkle proof This function assumes a final hashing step together with other_root

Trait Implementations§

source§

impl<T: Clone> Clone for Segment<T>

source§

fn clone(&self) -> Segment<T>

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<T: Debug> Debug for Segment<T>

source§

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

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

impl<T: PartialEq> PartialEq for Segment<T>

source§

fn eq(&self, other: &Segment<T>) -> bool

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

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

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

impl<T: Readable> Readable for Segment<T>

source§

fn read<R: Reader>(reader: &mut R) -> Result<Self, Error>

Reads the data necessary to this Readable from the provided reader
source§

impl<T: Writeable> Writeable for Segment<T>

source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Write the data held by this Writeable to the provided writer
source§

impl<T: Eq> Eq for Segment<T>

source§

impl<T> StructuralPartialEq for Segment<T>

Auto Trait Implementations§

§

impl<T> Freeze for Segment<T>

§

impl<T> RefUnwindSafe for Segment<T>
where T: RefUnwindSafe,

§

impl<T> Send for Segment<T>
where T: Send,

§

impl<T> Sync for Segment<T>
where T: Sync,

§

impl<T> Unpin for Segment<T>
where T: Unpin,

§

impl<T> UnwindSafe for Segment<T>
where T: UnwindSafe,

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> CloneAny for T
where T: Any + Clone,

source§

fn clone_any(&self) -> Box<dyn CloneAny>

source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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.
source§

impl<T> DebugAny for T
where T: Any + Debug,

source§

impl<T> UnsafeAny for T
where T: Any,