pub enum BlockHeader {
V1(BlockHeaderV1),
V2(BlockHeaderV2),
}
Expand description
The versioned header portion of a block. It encapsulates different variants of the BlockHeader struct.
Variants§
V1(BlockHeaderV1)
The legacy, initial version of the header portion of a block.
V2(BlockHeaderV2)
The version 2 of the header portion of a block.
Implementations§
Source§impl BlockHeader
impl BlockHeader
Sourcepub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Returns the hash of this block header.
Sourcepub fn parent_hash(&self) -> &BlockHash
pub fn parent_hash(&self) -> &BlockHash
Returns the parent block’s hash.
Sourcepub fn state_root_hash(&self) -> &Digest
pub fn state_root_hash(&self) -> &Digest
Returns the root hash of global state after the deploys in this block have been executed.
Sourcepub fn random_bit(&self) -> bool
pub fn random_bit(&self) -> bool
Returns a random bit needed for initializing a future era.
Sourcepub fn accumulated_seed(&self) -> &Digest
pub fn accumulated_seed(&self) -> &Digest
Returns a seed needed for initializing a future era.
Sourcepub fn clone_era_end(&self) -> Option<EraEnd>
pub fn clone_era_end(&self) -> Option<EraEnd>
Returns the EraEnd
of a block if it is a switch block.
Sourcepub fn maybe_equivocators(&self) -> Option<&[PublicKey]>
pub fn maybe_equivocators(&self) -> Option<&[PublicKey]>
Returns equivocators if the header is of a switch block.
Sourcepub fn maybe_inactive_validators(&self) -> Option<&[PublicKey]>
pub fn maybe_inactive_validators(&self) -> Option<&[PublicKey]>
Returns equivocators if the header is of a switch block.
Sourcepub fn next_block_era_id(&self) -> EraId
pub fn next_block_era_id(&self) -> EraId
Returns the era ID in which the next block would be created (i.e. this block’s era ID, or its successor if this is a switch block).
Sourcepub fn protocol_version(&self) -> ProtocolVersion
pub fn protocol_version(&self) -> ProtocolVersion
Returns the protocol version of the network from when this block was created.
Sourcepub fn is_switch_block(&self) -> bool
pub fn is_switch_block(&self) -> bool
Returns true
if this block is the last one in the current era.
Sourcepub fn next_era_validator_weights(&self) -> Option<&BTreeMap<PublicKey, U512>>
pub fn next_era_validator_weights(&self) -> Option<&BTreeMap<PublicKey, U512>>
Returns the validators for the upcoming era and their respective weights (if this is a switch block).
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Returns true
if this block is the Genesis block, i.e. has height 0 and era 0.
Sourcepub fn is_last_block_before_activation(
&self,
protocol_config: &ProtocolConfig,
) -> bool
Available on crate feature std
only.
pub fn is_last_block_before_activation( &self, protocol_config: &ProtocolConfig, ) -> bool
std
only.Returns true
if this block belongs to the last block before the upgrade to the
current protocol version.
Trait Implementations§
Source§impl Clone for BlockHeader
impl Clone for BlockHeader
Source§fn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl DataSize for BlockHeader
impl DataSize for BlockHeader
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true
, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC
is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl Debug for BlockHeader
impl Debug for BlockHeader
Source§impl<'de> Deserialize<'de> for BlockHeader
impl<'de> Deserialize<'de> for BlockHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for BlockHeader
impl Display for BlockHeader
Source§impl From<BlockHeaderV1> for BlockHeader
impl From<BlockHeaderV1> for BlockHeader
Source§fn from(header: BlockHeaderV1) -> Self
fn from(header: BlockHeaderV1) -> Self
Source§impl From<BlockHeaderV2> for BlockHeader
impl From<BlockHeaderV2> for BlockHeader
Source§fn from(header: BlockHeaderV2) -> Self
fn from(header: BlockHeaderV2) -> Self
Source§impl FromBytes for BlockHeader
impl FromBytes for BlockHeader
Source§impl JsonSchema for BlockHeader
impl JsonSchema for BlockHeader
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl PartialEq for BlockHeader
impl PartialEq for BlockHeader
Source§impl Serialize for BlockHeader
impl Serialize for BlockHeader
Source§impl ToBytes for BlockHeader
impl ToBytes for BlockHeader
Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Vec<u8>
which would be returned from a successful call to
to_bytes()
or into_bytes()
. The data is not actually serialized, so this call is
relatively cheap.impl Eq for BlockHeader
impl StructuralPartialEq for BlockHeader
Auto Trait Implementations§
impl !Freeze for BlockHeader
impl RefUnwindSafe for BlockHeader
impl Send for BlockHeader
impl Sync for BlockHeader
impl Unpin for BlockHeader
impl UnwindSafe for BlockHeader
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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