pub enum BlockHeader<'a> {
BeaconChain(BeaconChainHeader<'a>),
IntermediateShard(IntermediateShardHeader<'a>),
LeafShard(LeafShardHeader<'a>),
}
Variants§
BeaconChain(BeaconChainHeader<'a>)
Block header corresponds to the beacon chain
IntermediateShard(IntermediateShardHeader<'a>)
Block header corresponds to an intermediate shard
LeafShard(LeafShardHeader<'a>)
Block header corresponds to a leaf shard
Implementations§
Source§impl<'a> BlockHeader<'a>
impl<'a> BlockHeader<'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
should be 8-bytes 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 header’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<OwnedBlockHeader, OwnedBlockHeaderError>
pub fn to_owned(self) -> Result<OwnedBlockHeader, OwnedBlockHeaderError>
Create an owned version of this header
Sourcepub fn pre_seal_hash(&self) -> Blake3Hash
pub fn pre_seal_hash(&self) -> Blake3Hash
Hash of the block before seal is applied to it
Sourcepub fn is_seal_valid(&self) -> bool
pub fn is_seal_valid(&self) -> bool
Verify seal against BlockHeader::pre_seal_hash()
Sourcepub fn root(&self) -> BlockRoot
pub fn root(&self) -> BlockRoot
Compute block root out of this header.
Block root is a Merkle Tree Root. The leaves are derived from individual fields in
SharedBlockHeader
and other fields of this enum in the declaration order.
Note that this method does a bunch of hashing and if hash is needed often, should be cached.
Trait Implementations§
Source§impl<'a> Clone for BlockHeader<'a>
impl<'a> Clone for BlockHeader<'a>
Source§fn clone(&self) -> BlockHeader<'a>
fn clone(&self) -> BlockHeader<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for BlockHeader<'a>
impl<'a> Debug for BlockHeader<'a>
Source§impl<'a> Deref for BlockHeader<'a>
impl<'a> Deref for BlockHeader<'a>
Source§impl<'a> From<BeaconChainHeader<'a>> for BlockHeader<'a>
impl<'a> From<BeaconChainHeader<'a>> for BlockHeader<'a>
Source§fn from(value: BeaconChainHeader<'a>) -> Self
fn from(value: BeaconChainHeader<'a>) -> Self
Source§impl<'a> From<IntermediateShardHeader<'a>> for BlockHeader<'a>
impl<'a> From<IntermediateShardHeader<'a>> for BlockHeader<'a>
Source§fn from(value: IntermediateShardHeader<'a>) -> Self
fn from(value: IntermediateShardHeader<'a>) -> Self
Source§impl<'a> From<LeafShardHeader<'a>> for BlockHeader<'a>
impl<'a> From<LeafShardHeader<'a>> for BlockHeader<'a>
Source§fn from(value: LeafShardHeader<'a>) -> Self
fn from(value: LeafShardHeader<'a>) -> Self
Source§impl<'a> GenericBlockHeader<'a> for BlockHeader<'a>
impl<'a> GenericBlockHeader<'a> for BlockHeader<'a>
impl<'a> Copy for BlockHeader<'a>
Auto Trait Implementations§
impl<'a> Freeze for BlockHeader<'a>
impl<'a> RefUnwindSafe for BlockHeader<'a>
impl<'a> Send for BlockHeader<'a>
impl<'a> Sync for BlockHeader<'a>
impl<'a> Unpin for BlockHeader<'a>
impl<'a> UnwindSafe for BlockHeader<'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