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]) -> 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. The shard kind of the header is that of the shard index
in its prefix, see Self::shard_kind_from_bytes().
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 shard_kind_from_bytes(bytes: &[u8]) -> Option<RealShardKind>
pub fn shard_kind_from_bytes(bytes: &[u8]) -> Option<RealShardKind>
Shard kind of the header that bytes start with.
Headers of all shard kinds start with BlockHeaderPrefix, so the shard kind is that of
its shard index. Returns None if there are too few bytes for the prefix, they are not
8-bytes aligned or the shard index doesn’t correspond to a real shard.
Sourcepub fn to_owned(self) -> OwnedBlockHeader
pub fn to_owned(self) -> OwnedBlockHeader
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_sealed_correctly(&self) -> bool
pub fn is_sealed_correctly(&self) -> bool
Verify seal against BlockHeader::pre_seal_hash() and check that its public key hash
corresponds to the solution
Sourcepub fn root(&self) -> impl Deref<Target = BlockRoot> + Send + Sync
pub fn root(&self) -> impl Deref<Target = BlockRoot> + Send + Sync
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 computes root by doing a bunch of hashing. The result is then cached
if alloc feature is enabled.
Trait Implementations§
Source§impl<'a> Clone for BlockHeader<'a>
impl<'a> Clone for BlockHeader<'a>
Source§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
Auto Trait Implementations§
impl<'a> !Freeze for BlockHeader<'a>
impl<'a> Forget for BlockHeader<'a>
impl<'a> Move for BlockHeader<'a>
impl<'a> RefUnwindSafe for BlockHeader<'a>
impl<'a> Send for BlockHeader<'a>where
&'a BlockHeaderPrefix: Send,
&'a BlockHeaderResult: Send,
&'a BlockHeaderConsensusInfo: Send,
&'a BlockHeaderEd25519Seal: Send,
&'a Blake3Hash: Send,
NonZero<u32>: Send,
NonZero<u16>: Send,
&'a SuperSegmentRoot: Send,
&'a BlockHeaderPotParametersChange: Send,
&'a [u8]: Send,
OnceLock<BlockRoot>: Send,
&'a BlockHeaderBeaconChainInfo: Send,
impl<'a> Sync for BlockHeader<'a>
impl<'a> Unpin for BlockHeader<'a>where
&'a BlockHeaderPrefix: Unpin,
&'a BlockHeaderResult: Unpin,
&'a BlockHeaderConsensusInfo: Unpin,
&'a BlockHeaderEd25519Seal: Unpin,
&'a Blake3Hash: Unpin,
NonZero<u32>: Unpin,
NonZero<u16>: Unpin,
&'a SuperSegmentRoot: Unpin,
&'a BlockHeaderPotParametersChange: Unpin,
&'a [u8]: Unpin,
Align4<u32>: Unpin,
&'a BlockHeaderBeaconChainInfo: Unpin,
impl<'a> UnsafeUnpin for BlockHeader<'a>where
&'a BlockHeaderPrefix: UnsafeUnpin,
&'a BlockHeaderResult: UnsafeUnpin,
&'a BlockHeaderConsensusInfo: UnsafeUnpin,
&'a BlockHeaderEd25519Seal: UnsafeUnpin,
&'a Blake3Hash: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
NonZeroU16Inner: UnsafeUnpin,
&'a SuperSegmentRoot: UnsafeUnpin,
&'a BlockHeaderPotParametersChange: UnsafeUnpin,
&'a [u8]: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
PhantomData<BlockRoot>: UnsafeUnpin,
&'a BlockHeaderBeaconChainInfo: UnsafeUnpin,
impl<'a> UnwindSafe for BlockHeader<'a>where
&'a BlockHeaderPrefix: UnwindSafe,
&'a BlockHeaderResult: UnwindSafe,
&'a BlockHeaderConsensusInfo: UnwindSafe,
&'a BlockHeaderEd25519Seal: UnwindSafe,
&'a Blake3Hash: UnwindSafe,
NonZero<u32>: UnwindSafe,
NonZero<u16>: UnwindSafe,
&'a SuperSegmentRoot: UnwindSafe,
&'a BlockHeaderPotParametersChange: UnwindSafe,
&'a [u8]: UnwindSafe,
OnceLock<BlockRoot>: UnwindSafe,
&'a BlockHeaderBeaconChainInfo: UnwindSafe,
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