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.
Header and body will be checked for basic internal consistencies body and that they match each other, but no consensus verification is done.
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.
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) -> Result<OwnedBlock, OwnedBlockError>
pub fn to_owned(self) -> Result<OwnedBlock, OwnedBlockError>
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
Source§impl<'a> GenericBlock<'a> for Block<'a>
impl<'a> GenericBlock<'a> for Block<'a>
Source§type Header = BlockHeader<'a>
type Header = BlockHeader<'a>
Source§type Owned = OwnedBlock
type Owned = OwnedBlock
Source§fn try_to_owned(self) -> Option<Self::Owned>
fn try_to_owned(self) -> Option<Self::Owned>
impl<'a> Copy for Block<'a>
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