pub enum BlockHeader {
BlockHeaderV1(BlockHeaderV1),
BlockHeaderV2(BlockHeaderV2),
BlockHeaderV3(BlockHeaderV3),
BlockHeaderV4(BlockHeaderV4),
BlockHeaderV5(BlockHeaderV5),
BlockHeaderV6(BlockHeaderV6),
BlockHeaderV7(BlockHeaderV7),
}Expand description
Versioned BlockHeader data structure. For each next version, document what are the changes between versions.
Variants§
BlockHeaderV1(BlockHeaderV1)
BlockHeaderV2(BlockHeaderV2)
BlockHeaderV3(BlockHeaderV3)
BlockHeaderV4(BlockHeaderV4)
BlockHeaderV5(BlockHeaderV5)
BlockHeaderV6(BlockHeaderV6)
BlockHeaderV7(BlockHeaderV7)
Implementations§
Source§impl BlockHeader
impl BlockHeader
pub fn compute_inner_hash(inner_lite: &[u8], inner_rest: &[u8]) -> CryptoHash
pub fn compute_hash( prev_hash: CryptoHash, inner_lite: &[u8], inner_rest: &[u8], ) -> CryptoHash
Sourcepub fn new(
current_protocol_version: ProtocolVersion,
latest_protocol_version: ProtocolVersion,
height: BlockHeight,
prev_hash: CryptoHash,
block_body_hash: CryptoHash,
prev_state_root: MerkleHash,
prev_chunk_outgoing_receipts_root: MerkleHash,
chunk_headers_root: MerkleHash,
chunk_tx_root: MerkleHash,
outcome_root: MerkleHash,
timestamp: u64,
random_value: CryptoHash,
prev_validator_proposals: Vec<ValidatorStake>,
chunk_mask: Vec<bool>,
block_ordinal: NumBlocks,
epoch_id: EpochId,
next_epoch_id: EpochId,
next_gas_price: Balance,
total_supply: Balance,
signer: &ValidatorSigner,
last_final_block: CryptoHash,
last_ds_final_block: CryptoHash,
epoch_sync_data_hash: Option<CryptoHash>,
approvals: Vec<Option<Box<Signature>>>,
next_bp_hash: CryptoHash,
block_merkle_root: CryptoHash,
prev_height: BlockHeight,
chunk_endorsements: Option<ChunkEndorsementsBitmap>,
shard_split: Option<(ShardId, AccountId)>,
prev_last_certified_block_epoch_id: Option<EpochId>,
spice_chunk_endorsement_stats: Option<Vec<SpiceChunkEndorsementStats>>,
) -> Self
pub fn new( current_protocol_version: ProtocolVersion, latest_protocol_version: ProtocolVersion, height: BlockHeight, prev_hash: CryptoHash, block_body_hash: CryptoHash, prev_state_root: MerkleHash, prev_chunk_outgoing_receipts_root: MerkleHash, chunk_headers_root: MerkleHash, chunk_tx_root: MerkleHash, outcome_root: MerkleHash, timestamp: u64, random_value: CryptoHash, prev_validator_proposals: Vec<ValidatorStake>, chunk_mask: Vec<bool>, block_ordinal: NumBlocks, epoch_id: EpochId, next_epoch_id: EpochId, next_gas_price: Balance, total_supply: Balance, signer: &ValidatorSigner, last_final_block: CryptoHash, last_ds_final_block: CryptoHash, epoch_sync_data_hash: Option<CryptoHash>, approvals: Vec<Option<Box<Signature>>>, next_bp_hash: CryptoHash, block_merkle_root: CryptoHash, prev_height: BlockHeight, chunk_endorsements: Option<ChunkEndorsementsBitmap>, shard_split: Option<(ShardId, AccountId)>, prev_last_certified_block_epoch_id: Option<EpochId>, spice_chunk_endorsement_stats: Option<Vec<SpiceChunkEndorsementStats>>, ) -> Self
Creates BlockHeader for a newly produced block.
Sourcepub fn from_view(
expected_hash: &CryptoHash,
epoch_protocol_version: ProtocolVersion,
height: BlockHeight,
prev_hash: CryptoHash,
block_body_hash: CryptoHash,
prev_state_root: MerkleHash,
prev_chunk_outgoing_receipts_root: MerkleHash,
chunk_headers_root: MerkleHash,
chunk_tx_root: MerkleHash,
outcome_root: MerkleHash,
timestamp: u64,
random_value: CryptoHash,
prev_validator_proposals: Vec<ValidatorStake>,
chunk_mask: Vec<bool>,
block_ordinal: NumBlocks,
epoch_id: EpochId,
next_epoch_id: EpochId,
next_gas_price: Balance,
total_supply: Balance,
signature: Signature,
last_final_block: CryptoHash,
last_ds_final_block: CryptoHash,
epoch_sync_data_hash: Option<CryptoHash>,
approvals: Vec<Option<Box<Signature>>>,
next_bp_hash: CryptoHash,
block_merkle_root: CryptoHash,
prev_height: BlockHeight,
chunk_endorsements: Option<ChunkEndorsementsBitmap>,
shard_split: Option<(ShardId, AccountId)>,
prev_last_certified_block_epoch_id: Option<EpochId>,
spice_chunk_endorsement_stats: Option<Vec<SpiceChunkEndorsementStats>>,
) -> Self
pub fn from_view( expected_hash: &CryptoHash, epoch_protocol_version: ProtocolVersion, height: BlockHeight, prev_hash: CryptoHash, block_body_hash: CryptoHash, prev_state_root: MerkleHash, prev_chunk_outgoing_receipts_root: MerkleHash, chunk_headers_root: MerkleHash, chunk_tx_root: MerkleHash, outcome_root: MerkleHash, timestamp: u64, random_value: CryptoHash, prev_validator_proposals: Vec<ValidatorStake>, chunk_mask: Vec<bool>, block_ordinal: NumBlocks, epoch_id: EpochId, next_epoch_id: EpochId, next_gas_price: Balance, total_supply: Balance, signature: Signature, last_final_block: CryptoHash, last_ds_final_block: CryptoHash, epoch_sync_data_hash: Option<CryptoHash>, approvals: Vec<Option<Box<Signature>>>, next_bp_hash: CryptoHash, block_merkle_root: CryptoHash, prev_height: BlockHeight, chunk_endorsements: Option<ChunkEndorsementsBitmap>, shard_split: Option<(ShardId, AccountId)>, prev_last_certified_block_epoch_id: Option<EpochId>, spice_chunk_endorsement_stats: Option<Vec<SpiceChunkEndorsementStats>>, ) -> Self
Creates a new BlockHeader from information in the view of an existing block.
pub fn genesis( genesis_protocol_version: ProtocolVersion, height: BlockHeight, state_root: MerkleHash, block_body_hash: CryptoHash, prev_chunk_outgoing_receipts_root: MerkleHash, chunk_headers_root: MerkleHash, chunk_tx_root: MerkleHash, num_shards: u64, timestamp: Utc, initial_gas_price: Balance, initial_total_supply: Balance, next_bp_hash: CryptoHash, ) -> Self
pub fn is_genesis(&self) -> bool
pub fn hash(&self) -> &CryptoHash
pub fn prev_hash(&self) -> &CryptoHash
pub fn signature(&self) -> &Signature
pub fn height(&self) -> BlockHeight
pub fn prev_height(&self) -> Option<BlockHeight>
pub fn epoch_id(&self) -> &EpochId
pub fn next_epoch_id(&self) -> &EpochId
pub fn prev_state_root(&self) -> &MerkleHash
pub fn prev_chunk_outgoing_receipts_root(&self) -> &MerkleHash
pub fn chunk_headers_root(&self) -> &MerkleHash
pub fn chunk_tx_root(&self) -> &MerkleHash
pub fn chunks_included(&self) -> u64
pub fn outcome_root(&self) -> &MerkleHash
pub fn block_body_hash(&self) -> Option<CryptoHash>
pub fn raw_timestamp(&self) -> u64
pub fn prev_validator_proposals(&self) -> ValidatorStakeIter<'_> ⓘ
pub fn chunk_mask(&self) -> &[bool]
pub fn block_ordinal(&self) -> NumBlocks
pub fn next_gas_price(&self) -> Balance
pub fn total_supply(&self) -> Balance
pub fn random_value(&self) -> &CryptoHash
pub fn last_final_block(&self) -> &CryptoHash
Sourcepub fn last_final_block_for_height(
&self,
target_height: BlockHeight,
) -> &CryptoHash
pub fn last_final_block_for_height( &self, target_height: BlockHeight, ) -> &CryptoHash
Get the hash of what will be considered the last final block after a new block with
target_height is produced on top of this (self) block.
pub fn last_ds_final_block(&self) -> &CryptoHash
pub fn next_bp_hash(&self) -> &CryptoHash
pub fn block_merkle_root(&self) -> &CryptoHash
pub fn epoch_sync_data_hash(&self) -> Option<CryptoHash>
pub fn approvals(&self) -> &[Option<Box<Signature>>]
Sourcepub fn verify_block_producer(&self, public_key: &PublicKey) -> bool
pub fn verify_block_producer(&self, public_key: &PublicKey) -> bool
Verifies that given public key produced the block.
pub fn timestamp(&self) -> Utc
pub fn num_approvals(&self) -> u64
pub fn verify_chunks_included(&self) -> bool
pub fn latest_protocol_version(&self) -> u32
pub fn inner_lite_bytes(&self) -> Vec<u8> ⓘ
pub fn inner_rest_bytes(&self) -> Vec<u8> ⓘ
pub fn chunk_endorsements(&self) -> Option<&ChunkEndorsementsBitmap>
pub fn inner_lite(&self) -> &BlockHeaderInnerLite
Sourcepub fn challenges_present(&self) -> bool
pub fn challenges_present(&self) -> bool
As challenges are now deprecated and not supported, a valid block should not have challenges.
Sourcepub fn shard_split(&self) -> Option<&(ShardId, AccountId)>
pub fn shard_split(&self) -> Option<&(ShardId, AccountId)>
Shard ID and boundary account for the upcoming resharding. This field may be set only for the last block of an epoch. Split proposed at the end of epoch N will be effective since the beginning of epoch N+2.
Sourcepub fn prev_last_certified_block_epoch_id(&self) -> Option<&EpochId>
pub fn prev_last_certified_block_epoch_id(&self) -> Option<&EpochId>
Epoch ID of the last block whose spice execution results are certified.
Returns None for header versions prior to V7.
Sourcepub fn spice_chunk_endorsement_stats(
&self,
) -> Option<&[SpiceChunkEndorsementStats]>
pub fn spice_chunk_endorsement_stats( &self, ) -> Option<&[SpiceChunkEndorsementStats]>
Set only on the last block of an epoch; None before header V7.
See SpiceChunkEndorsementStats.
Source§impl BlockHeader
impl BlockHeader
pub fn prod_genesis( height: BlockHeight, state_root: MerkleHash, prev_chunk_outgoing_receipts_root: MerkleHash, chunk_headers_root: MerkleHash, chunk_tx_root: MerkleHash, timestamp: Utc, initial_gas_price: Balance, initial_total_supply: Balance, next_bp_hash: CryptoHash, ) -> Self
Trait Implementations§
Source§impl BorshDeserialize for BlockHeader
impl BorshDeserialize for BlockHeader
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for BlockHeader
impl BorshSerialize for BlockHeader
Source§impl Clone for BlockHeader
impl Clone for BlockHeader
Source§fn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockHeader
impl Debug for BlockHeader
Source§impl EnumExt for BlockHeader
impl EnumExt for BlockHeader
impl Eq for BlockHeader
Source§impl From<&BlockHeader> for BlockHeaderView
impl From<&BlockHeader> for BlockHeaderView
Source§fn from(header: &BlockHeader) -> Self
fn from(header: &BlockHeader) -> Self
Source§impl From<BlockHeader> for BlockHeaderInnerLiteView
impl From<BlockHeader> for BlockHeaderInnerLiteView
Source§fn from(header: BlockHeader) -> Self
fn from(header: BlockHeader) -> Self
Source§impl From<BlockHeader> for LightClientBlockLiteView
impl From<BlockHeader> for LightClientBlockLiteView
Source§fn from(header: BlockHeader) -> Self
fn from(header: BlockHeader) -> Self
Source§impl From<BlockHeaderView> for BlockHeader
impl From<BlockHeaderView> for BlockHeader
Source§fn from(view: BlockHeaderView) -> Self
fn from(view: BlockHeaderView) -> Self
Source§impl PartialEq for BlockHeader
impl PartialEq for BlockHeader
Source§impl Serialize for BlockHeader
impl Serialize 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 UnsafeUnpin 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<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.