pub struct OwnSegments<'a> {
pub first_local_segment_index: LocalSegmentIndex,
pub segment_roots: &'a [SegmentRoot],
}Expand description
Own segments produced by a shard.
They have between 1 and u8::MAX segment roots, which is how many a body can store. The local
segment index after the last segment root fits into u64, because that is where the next
segment of the shard starts. Local segment indices never get close to u64::MAX in practice.
Fields§
§first_local_segment_index: LocalSegmentIndexLocal segment index of the first own segment root
segment_roots: &'a [SegmentRoot]Segment roots produced by a shard
Implementations§
Source§impl<'a> OwnSegments<'a>
impl<'a> OwnSegments<'a>
Sourcepub fn new(
first_local_segment_index: LocalSegmentIndex,
segment_roots: &'a [SegmentRoot],
) -> Option<Self>
pub fn new( first_local_segment_index: LocalSegmentIndex, segment_roots: &'a [SegmentRoot], ) -> Option<Self>
Create own segments from the local segment index of the first segment root and the roots.
Returns None if there are no segment roots, more than u8::MAX of them, or the local
segment index after the last one doesn’t fit into u64.
Sourcepub fn num_segment_roots(&self) -> NonZeroU8
pub fn num_segment_roots(&self) -> NonZeroU8
Number of segment roots
Sourcepub fn iter(
&self,
) -> impl ExactSizeIterator<Item = (LocalSegmentIndex, &'a SegmentRoot)> + TrustedLen + use<'a>
pub fn iter( &self, ) -> impl ExactSizeIterator<Item = (LocalSegmentIndex, &'a SegmentRoot)> + TrustedLen + use<'a>
Iterator over segment roots with their local segment indices
Sourcepub fn root(&self) -> Blake3Hash
pub fn root(&self) -> Blake3Hash
Compute the root of own segments
Sourcepub fn root_with_shard_index(&self, shard_index: ShardIndex) -> Blake3Hash
pub fn root_with_shard_index(&self, shard_index: ShardIndex) -> Blake3Hash
Compute the root of own segments while mixing in shard index.
This method is useful for deriving roots on intermediate shard that can be verified by the beacon chain later (which will have just shard index available rather than the whole leaf shard block header).
Trait Implementations§
Source§impl<'a> Clone for OwnSegments<'a>
impl<'a> Clone for OwnSegments<'a>
impl<'a> Copy for OwnSegments<'a>
Auto Trait Implementations§
impl<'a> Forget for OwnSegments<'a>
impl<'a> Freeze for OwnSegments<'a>
impl<'a> RefUnwindSafe for OwnSegments<'a>
impl<'a> Send for OwnSegments<'a>
impl<'a> Sync for OwnSegments<'a>
impl<'a> Unpin for OwnSegments<'a>
impl<'a> UnsafeUnpin for OwnSegments<'a>
impl<'a> UnwindSafe for OwnSegments<'a>
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more