pub enum Block {
BlockV1(Arc<BlockV1>),
BlockV2(Arc<BlockV2>),
BlockV3(Arc<BlockV3>),
}Expand description
Versioned Block data structure. For each next version, document what are the changes between versions.
Variants§
Implementations§
Source§impl Block
impl Block
Sourcepub fn genesis(
genesis_protocol_version: ProtocolVersion,
chunks: Vec<ShardChunkHeader>,
timestamp: DateTime<Utc>,
height: BlockHeight,
initial_gas_price: Balance,
initial_total_supply: Balance,
next_bp_hash: CryptoHash,
) -> Self
pub fn genesis( genesis_protocol_version: ProtocolVersion, chunks: Vec<ShardChunkHeader>, timestamp: DateTime<Utc>, height: BlockHeight, initial_gas_price: Balance, initial_total_supply: Balance, next_bp_hash: CryptoHash, ) -> Self
Returns genesis block for given genesis date and state root.
Sourcepub fn produce(
this_epoch_protocol_version: ProtocolVersion,
next_epoch_protocol_version: ProtocolVersion,
prev: &BlockHeader,
height: BlockHeight,
block_ordinal: NumBlocks,
chunks: Vec<ShardChunkHeader>,
epoch_id: EpochId,
next_epoch_id: EpochId,
epoch_sync_data_hash: Option<CryptoHash>,
approvals: Vec<Option<Box<Signature>>>,
gas_price_adjustment_rate: Rational32,
min_gas_price: Balance,
max_gas_price: Balance,
minted_amount: Option<Balance>,
challenges_result: ChallengesResult,
challenges: Challenges,
signer: &dyn ValidatorSigner,
next_bp_hash: CryptoHash,
block_merkle_root: CryptoHash,
timestamp_override: Option<DateTime<Utc>>,
) -> Self
pub fn produce( this_epoch_protocol_version: ProtocolVersion, next_epoch_protocol_version: ProtocolVersion, prev: &BlockHeader, height: BlockHeight, block_ordinal: NumBlocks, chunks: Vec<ShardChunkHeader>, epoch_id: EpochId, next_epoch_id: EpochId, epoch_sync_data_hash: Option<CryptoHash>, approvals: Vec<Option<Box<Signature>>>, gas_price_adjustment_rate: Rational32, min_gas_price: Balance, max_gas_price: Balance, minted_amount: Option<Balance>, challenges_result: ChallengesResult, challenges: Challenges, signer: &dyn ValidatorSigner, next_bp_hash: CryptoHash, block_merkle_root: CryptoHash, timestamp_override: Option<DateTime<Utc>>, ) -> Self
Produces new block from header of previous block, current state root and set of transactions.
pub fn verify_total_supply( &self, prev_total_supply: Balance, minted_amount: Option<Balance>, ) -> bool
pub fn verify_gas_price( &self, gas_price: Balance, min_gas_price: Balance, max_gas_price: Balance, gas_price_adjustment_rate: Rational32, ) -> bool
Sourcepub fn compute_next_gas_price(
gas_price: Balance,
gas_used: Gas,
gas_limit: Gas,
gas_price_adjustment_rate: Rational32,
min_gas_price: Balance,
max_gas_price: Balance,
) -> Balance
pub fn compute_next_gas_price( gas_price: Balance, gas_used: Gas, gas_limit: Gas, gas_price_adjustment_rate: Rational32, min_gas_price: Balance, max_gas_price: Balance, ) -> Balance
Computes gas price for applying chunks in the next block according to the formula: next_gas_price = gas_price * (1 + (gas_used/gas_limit - 1/2) * adjustment_rate) and clamped between min_gas_price and max_gas_price.
pub fn compute_state_root<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, ) -> CryptoHash
pub fn compute_block_body_hash_impl(body: &BlockBody) -> CryptoHash
pub fn compute_chunk_prev_outgoing_receipts_root<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, ) -> CryptoHash
pub fn compute_chunk_headers_root<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, ) -> (CryptoHash, Vec<MerklePath>)
pub fn compute_chunk_tx_root<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, ) -> CryptoHash
pub fn compute_outcome_root<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, ) -> CryptoHash
pub fn compute_challenges_root(challenges: &Challenges) -> CryptoHash
pub fn compute_gas_used<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, height: BlockHeight, ) -> Gas
pub fn compute_gas_limit<'a, T: IntoIterator<Item = &'a ShardChunkHeader>>( chunks: T, height: BlockHeight, ) -> Gas
pub fn validate_chunk_header_proof( chunk: &ShardChunkHeader, chunk_root: &CryptoHash, merkle_path: &MerklePath, ) -> bool
pub fn header(&self) -> &BlockHeader
pub fn chunks(&self) -> ChunksCollection<'_>
pub fn challenges(&self) -> &Challenges
pub fn vrf_value(&self) -> &Value
pub fn vrf_proof(&self) -> &Proof
pub fn hash(&self) -> &CryptoHash
pub fn compute_block_body_hash(&self) -> Option<CryptoHash>
Sourcepub fn check_validity(&self) -> Result<(), BlockValidityError>
pub fn check_validity(&self) -> Result<(), BlockValidityError>
Checks that block content matches block hash, with the possible exception of chunk signatures
Source§impl Block
impl Block
pub fn mut_header(&mut self) -> &mut BlockHeader
pub fn set_chunks(&mut self, chunks: Vec<ShardChunkHeader>)
Trait Implementations§
Source§impl BorshDeserialize for Block
impl BorshDeserialize for Block
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>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for Block
impl BorshSerialize for Block
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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
Compare self to
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
Compare self to
key and return true if they are equal.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§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>
Converts
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>
Converts
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