pub struct BlockHeaderV2 { /* private fields */ }
Expand description
The header portion of a block.
Implementations§
Source§impl BlockHeaderV2
impl BlockHeaderV2
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 era_end(&self) -> Option<&EraEndV2>
pub fn era_end(&self) -> Option<&EraEndV2>
Returns the EraEnd
of a block if it is 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 proposer(&self) -> &PublicKey
pub fn proposer(&self) -> &PublicKey
Returns the public key of the validator which proposed the block.
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 current_gas_price(&self) -> u8
pub fn current_gas_price(&self) -> u8
Returns the gas price for the given block.
Sourcepub fn last_switch_block_hash(&self) -> Option<BlockHash>
pub fn last_switch_block_hash(&self) -> Option<BlockHash>
Returns the hash for the last relevant switch block.
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 BlockHeaderV2
impl Clone for BlockHeaderV2
Source§fn clone(&self) -> BlockHeaderV2
fn clone(&self) -> BlockHeaderV2
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl DataSize for BlockHeaderV2
impl DataSize for BlockHeaderV2
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 BlockHeaderV2
impl Debug for BlockHeaderV2
Source§impl<'de> Deserialize<'de> for BlockHeaderV2
impl<'de> Deserialize<'de> for BlockHeaderV2
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 BlockHeaderV2
impl Display for BlockHeaderV2
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 BlockHeaderV2
impl FromBytes for BlockHeaderV2
Source§impl JsonSchema for BlockHeaderV2
impl JsonSchema for BlockHeaderV2
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 BlockHeaderV2
impl PartialEq for BlockHeaderV2
Source§impl Serialize for BlockHeaderV2
impl Serialize for BlockHeaderV2
Source§impl ToBytes for BlockHeaderV2
impl ToBytes for BlockHeaderV2
Source§fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>
fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>
&self
into a mutable writer
.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 BlockHeaderV2
Auto Trait Implementations§
impl !Freeze for BlockHeaderV2
impl RefUnwindSafe for BlockHeaderV2
impl Send for BlockHeaderV2
impl Sync for BlockHeaderV2
impl Unpin for BlockHeaderV2
impl UnwindSafe for BlockHeaderV2
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