pub enum BlockBody<'a> {
BeaconChain(BeaconChainBody<'a>),
IntermediateShard(IntermediateShardBody<'a>),
LeafShard(LeafShardBody<'a>),
}
Expand description
Block body that together with BlockHeader
form a Block
Variants§
BeaconChain(BeaconChainBody<'a>)
Block body corresponds to the beacon chain
IntermediateShard(IntermediateShardBody<'a>)
Block body corresponds to an intermediate shard
LeafShard(LeafShardBody<'a>)
Block body corresponds to a leaf shard
Implementations§
Source§impl<'a> BlockBody<'a>
impl<'a> BlockBody<'a>
Sourcepub fn try_from_bytes(
bytes: &'a [u8],
shard_kind: ShardKind,
) -> Option<(Self, &'a [u8])>
pub fn try_from_bytes( bytes: &'a [u8], shard_kind: ShardKind, ) -> Option<(Self, &'a [u8])>
Try to create a new instance from provided bytes for provided shard index.
bytes
do not need to be aligned.
Returns an instance and remaining bytes on success, None
if too few bytes were given,
bytes are not properly aligned or input is otherwise invalid.
Sourcepub fn is_internally_consistent(&self) -> bool
pub fn is_internally_consistent(&self) -> bool
Check block body’s internal consistency
Sourcepub fn try_from_bytes_unchecked(
bytes: &'a [u8],
shard_kind: ShardKind,
) -> Option<(Self, &'a [u8])>
pub fn try_from_bytes_unchecked( bytes: &'a [u8], shard_kind: ShardKind, ) -> Option<(Self, &'a [u8])>
The same as Self::try_from_bytes()
, but for trusted input that skips some consistency
checks
Sourcepub fn to_owned(self) -> Result<OwnedBlockBody, OwnedBlockBodyError>
pub fn to_owned(self) -> Result<OwnedBlockBody, OwnedBlockBodyError>
Create an owned version of this body
Sourcepub fn root(&self) -> Blake3Hash
pub fn root(&self) -> Blake3Hash
Compute block body root.
Block body hash is actually a Merkle Tree Root. The leaves are derived from individual fields this enum in the declaration order.
Trait Implementations§
Source§impl<'a> From<BeaconChainBody<'a>> for BlockBody<'a>
impl<'a> From<BeaconChainBody<'a>> for BlockBody<'a>
Source§fn from(value: BeaconChainBody<'a>) -> Self
fn from(value: BeaconChainBody<'a>) -> Self
Source§impl<'a> From<IntermediateShardBody<'a>> for BlockBody<'a>
impl<'a> From<IntermediateShardBody<'a>> for BlockBody<'a>
Source§fn from(value: IntermediateShardBody<'a>) -> Self
fn from(value: IntermediateShardBody<'a>) -> Self
Source§impl<'a> From<LeafShardBody<'a>> for BlockBody<'a>
impl<'a> From<LeafShardBody<'a>> for BlockBody<'a>
Source§fn from(value: LeafShardBody<'a>) -> Self
fn from(value: LeafShardBody<'a>) -> Self
Source§impl<'a> GenericBlockBody<'a> for BlockBody<'a>
impl<'a> GenericBlockBody<'a> for BlockBody<'a>
Source§type Owned = OwnedBlockBody
type Owned = OwnedBlockBody
Source§fn try_to_owned(self) -> Option<Self::Owned>
fn try_to_owned(self) -> Option<Self::Owned>
Source§fn root(&self) -> Blake3Hash
fn root(&self) -> Blake3Hash
impl<'a> Copy for BlockBody<'a>
Auto Trait Implementations§
impl<'a> Freeze for BlockBody<'a>
impl<'a> RefUnwindSafe for BlockBody<'a>
impl<'a> Send for BlockBody<'a>
impl<'a> Sync for BlockBody<'a>
impl<'a> Unpin for BlockBody<'a>
impl<'a> UnwindSafe for BlockBody<'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