pub struct BeaconChainHeader<'a> {
pub shared: SharedBlockHeader<'a>,
pub child_shard_blocks: BlockHeaderChildShardBlocks<'a>,
pub consensus_parameters: BlockHeaderBeaconChainParameters<'a>,
pub pre_seal_bytes: &'a [u8],
}
Expand description
Block header that corresponds to the beacon chain
Fields§
Shared block header
child_shard_blocks: BlockHeaderChildShardBlocks<'a>
Information about child shard blocks
consensus_parameters: BlockHeaderBeaconChainParameters<'a>
Consensus parameters (on the beacon chain)
pre_seal_bytes: &'a [u8]
All bytes of the header except the seal
Implementations§
Source§impl<'a> BeaconChainHeader<'a>
impl<'a> BeaconChainHeader<'a>
Sourcepub fn try_from_bytes(bytes: &'a [u8]) -> Option<(Self, &'a [u8])>
pub fn try_from_bytes(bytes: &'a [u8]) -> Option<(Self, &'a [u8])>
Try to create a new instance from provided bytes.
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]) -> Option<(Self, &'a [u8])>
pub fn try_from_bytes_unchecked(bytes: &'a [u8]) -> 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<OwnedBeaconChainHeader, OwnedBeaconChainHeaderError>
pub fn to_owned( self, ) -> Result<OwnedBeaconChainHeader, OwnedBeaconChainHeaderError>
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 BeaconChainHeader::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 BeaconChainHeader<'a>
impl<'a> Clone for BeaconChainHeader<'a>
Source§fn clone(&self) -> BeaconChainHeader<'a>
fn clone(&self) -> BeaconChainHeader<'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 BeaconChainHeader<'a>
impl<'a> Debug for BeaconChainHeader<'a>
Source§impl<'a> Deref for BeaconChainHeader<'a>
impl<'a> Deref for BeaconChainHeader<'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> GenericBlockHeader<'a> for BeaconChainHeader<'a>
impl<'a> GenericBlockHeader<'a> for BeaconChainHeader<'a>
impl<'a> Copy for BeaconChainHeader<'a>
Auto Trait Implementations§
impl<'a> Freeze for BeaconChainHeader<'a>
impl<'a> RefUnwindSafe for BeaconChainHeader<'a>
impl<'a> Send for BeaconChainHeader<'a>
impl<'a> Sync for BeaconChainHeader<'a>
impl<'a> Unpin for BeaconChainHeader<'a>
impl<'a> UnwindSafe for BeaconChainHeader<'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