pub enum Block {
V1(BlockV1),
V2(BlockV2),
}
Expand description
A block after execution.
Variants§
Implementations§
Source§impl Block
impl Block
Sourcepub fn clone_header(&self) -> BlockHeader
pub fn clone_header(&self) -> BlockHeader
Clones the header, put it in the versioning enum, and returns it.
Sourcepub fn take_header(self) -> BlockHeader
pub fn take_header(self) -> BlockHeader
Returns the block’s header, consuming self
.
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 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 parent_hash(&self) -> &BlockHash
pub fn parent_hash(&self) -> &BlockHash
Returns the parent block’s hash.
Sourcepub fn proposer(&self) -> &PublicKey
pub fn proposer(&self) -> &PublicKey
Returns the public key of the validator which proposed the block.
Sourcepub fn clone_body(&self) -> BlockBody
pub fn clone_body(&self) -> BlockBody
Clone the body and wrap is up in the versioned Body
.
Sourcepub fn verify(&self) -> Result<(), BlockValidationError>
pub fn verify(&self) -> Result<(), BlockValidationError>
Check the integrity of a block by hashing its body and header
Sourcepub fn clone_era_end(&self) -> Option<EraEnd>
pub fn clone_era_end(&self) -> Option<EraEnd>
Clones the era end, put it in the versioning enum, and returns it.
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 is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Returns true
if this block is the first block of the chain, the genesis block.
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 rewarded_signatures(&self) -> &RewardedSignatures
pub fn rewarded_signatures(&self) -> &RewardedSignatures
List of identifiers for finality signatures for a particular past block.
Sourcepub fn maybe_current_gas_price(&self) -> Option<u8>
pub fn maybe_current_gas_price(&self) -> Option<u8>
Return the gas price for V2 block header.
Sourcepub fn transaction_count(&self) -> u64
pub fn transaction_count(&self) -> u64
Returns the count of transactions within a block.
Sourcepub fn all_transaction_hashes(
&self,
) -> impl Iterator<Item = TransactionHash> + '_
pub fn all_transaction_hashes( &self, ) -> impl Iterator<Item = TransactionHash> + '_
Returns a list of all transaction hashes in a block.
Sourcepub fn block_utilization(&self, transaction_config: TransactionConfig) -> u64
Available on crate feature std
only.
pub fn block_utilization(&self, transaction_config: TransactionConfig) -> u64
std
only.Returns the utilization of the block against a given chainspec.
Sourcepub fn has_hit_slot_capacity(
&self,
transaction_config: TransactionConfig,
) -> bool
Available on crate feature std
only.
pub fn has_hit_slot_capacity( &self, transaction_config: TransactionConfig, ) -> bool
std
only.Returns true if the block has reached capacity in any of its transaction limit.
Trait Implementations§
Source§impl DataSize for Block
impl DataSize for Block
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<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
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 From<JsonBlockWithSignatures> for Block
Available on crate features std
and json-schema
only.
impl From<JsonBlockWithSignatures> for Block
std
and json-schema
only.Source§fn from(block_with_signatures: JsonBlockWithSignatures) -> Self
fn from(block_with_signatures: JsonBlockWithSignatures) -> Self
Source§impl JsonSchema for Block
impl JsonSchema for Block
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 ToBytes for Block
impl ToBytes for Block
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 Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl !Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
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