Struct near_chain::chain::Chain[][src]

pub struct Chain {
    pub runtime_adapter: Arc<dyn RuntimeAdapter>,
    pub blocks_with_missing_chunks: MissingChunksPool<Orphan>,
    pub transaction_validity_period: NumBlocks,
    pub epoch_length: BlockHeightDelta,
    pub block_economics_config: BlockEconomicsConfig,
    pub doomslug_threshold_mode: DoomslugThresholdMode,
    // some fields omitted
}
Expand description

Facade to the blockchain block processing and storage. Provides current view on the state according to the chain state.

Fields

runtime_adapter: Arc<dyn RuntimeAdapter>blocks_with_missing_chunks: MissingChunksPool<Orphan>transaction_validity_period: NumBlocksepoch_length: BlockHeightDeltablock_economics_config: BlockEconomicsConfig

Block economics, relevant to changes when new block must be produced.

doomslug_threshold_mode: DoomslugThresholdMode

Implementations

Creates a light client block for the last final block from perspective of some other block

Arguments

  • header - the last finalized block seen from header (not pushed back) will be used to compute the light client block

Do Basic validation of a block upon receiving it. Check that header is valid and block is well-formed (various roots match).

Process a block header received during “header first” propagation.

Process a received or produced block, and unroll any orphans that may depend on it. Changes current state, and calls block_accepted callback in case block was successfully applied.

Process challenge to invalidate chain. This is done between blocks to unroll the chain as soon as possible and allow next block producer to skip invalid blocks.

Processes headers and adds them to store for syncing.

Returns if given block header is on the current chain.

Finds first of the given hashes that is known on the main chain.

pub fn reset_heads_post_state_sync<F, F2, F3>(
    &mut self,
    me: &Option<AccountId>,
    sync_hash: CryptoHash,
    block_accepted: F,
    block_misses_chunks: F2,
    on_challenge: F3
) -> Result<(), Error> where
    F: Copy + FnMut(AcceptedBlock),
    F2: Copy + FnMut(Vec<ShardChunkHeader>),
    F3: Copy + FnMut(ChallengeBody), 

Set the new head after state sync was completed if it is indeed newer. Check for potentially unlocked orphans after this update.

Check if any block with missing chunk is ready to be processed

Check for orphans, once a block is successfully added.

Apply transactions in chunks for the next epoch in blocks that were blocked on the state sync

Find a validator to forward transactions to

Find a validator that is responsible for a given shard to forward requests to

Get all execution outcomes generated when the chunk are applied

Implement block merkle proof retrieval.

Get merkle proof for block with hash block_hash in the merkle tree of head_block_hash.

Various chain getters.

Gets chain head.

Gets chain tail height

Gets chain header head.

Header of the block at the head of the block chain (not the same thing as header_head).

Get final head of the chain.

Gets a block by hash.

Gets a chunk from hash.

Gets a chunk from header.

Gets a block from the current chain by height.

Gets a block header by hash.

Returns block header from the canonical chain for given height if present.

Returns block header from the current chain defined by sync_hash for given height if present.

Get previous block header.

Returns hash of the first available block after genesis.

Check if block exists.

Get block extra that was computer after applying previous block.

Get chunk extra that was computed after applying chunk with given hash.

Get destination shard id for a given receipt id.

Get next block hash for which there is a new chunk for the shard.

Returns underlying ChainStore.

Returns mutable ChainStore.

Returns underlying RuntimeAdapter.

Returns genesis block.

Returns genesis block header.

Returns number of orphans currently in the orphan pool.

Returns number of orphans currently in the orphan pool.

Returns number of evicted orphans.

Check if hash is for a known orphan.

Check if hash is for a known chunk orphan.

Check if can sync with sync_hash

Get transaction result for given hash of transaction or receipt id on the canonical chain

Returns a vector of chunk headers, each of which corresponds to the previous chunk of a chunk in the block after prev_block This function is important when the block after prev_block has different number of chunks from prev_block. In block production and processing, often we need to get the previous chunks of chunks in the current block, this function provides a way to do so while handling sharding changes correctly. For example, if prev_block has two shards 0, 1 and the block after prev_block will have 4 shards 0, 1, 2, 3, 0 and 1 split from shard 0 and 2 and 3 split from shard 1. get_prev_chunks(runtime_adapter, prev_block) will return [prev_block.chunks()[0], prev_block.chunks()[0], prev_block.chunks()[1], prev_block.chunks()[1]]

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more