pub enum Block<'a> {
BeaconChain(BeaconChainBlock<'a>),
IntermediateShard(IntermediateShardBlock<'a>),
LeafShard(LeafShardBlock<'a>),
}
Expand description
Block that contains BlockHeader
and BlockBody
Variants§
BeaconChain(BeaconChainBlock<'a>)
Block corresponds to the beacon chain
IntermediateShard(IntermediateShardBlock<'a>)
Block corresponds to an intermediate shard
LeafShard(LeafShardBlock<'a>)
Block corresponds to a leaf shard
Implementations§
Source§impl<'a> Block<'a>
impl<'a> Block<'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.
bytes
should be 16-byte aligned.
Checks internal consistency of header, body, and block, but no consensus verification is
done. For unchecked version use Self::try_from_bytes_unchecked()
.
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’s internal consistency.
This is usually not necessary to be called explicitly since full internal consistency is
checked by Self::try_from_bytes()
internally.
NOTE: This only checks block-level internal consistency, header and block level internal consistency is checked separately.
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) -> OwnedBlock
pub fn to_owned(self) -> OwnedBlock
Create an owned version of this block
Trait Implementations§
Source§impl<'a> From<BeaconChainBlock<'a>> for Block<'a>
impl<'a> From<BeaconChainBlock<'a>> for Block<'a>
Source§fn from(value: BeaconChainBlock<'a>) -> Self
fn from(value: BeaconChainBlock<'a>) -> Self
Source§impl<'a> From<IntermediateShardBlock<'a>> for Block<'a>
impl<'a> From<IntermediateShardBlock<'a>> for Block<'a>
Source§fn from(value: IntermediateShardBlock<'a>) -> Self
fn from(value: IntermediateShardBlock<'a>) -> Self
Source§impl<'a> From<LeafShardBlock<'a>> for Block<'a>
impl<'a> From<LeafShardBlock<'a>> for Block<'a>
Source§fn from(value: LeafShardBlock<'a>) -> Self
fn from(value: LeafShardBlock<'a>) -> Self
Auto Trait Implementations§
impl<'a> Freeze for Block<'a>
impl<'a> !RefUnwindSafe for Block<'a>
impl<'a> Send for Block<'a>
impl<'a> Sync for Block<'a>
impl<'a> Unpin for Block<'a>
impl<'a> !UnwindSafe for Block<'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