Struct near_chain::ChainStore [−][src]
pub struct ChainStore { /* fields omitted */ }
Expand description
All chain-related database operations.
Implementations
pub fn get_state_changes_for_split_states(
&self,
block_hash: &CryptoHash,
shard_id: ShardId
) -> Result<StateChangesForSplitStates, Error>
pub fn get_outgoing_receipts_for_shard(
&mut self,
runtime_adapter: &dyn RuntimeAdapter,
prev_block_hash: CryptoHash,
shard_id: ShardId,
last_included_height: BlockHeight
) -> Result<Vec<Receipt>, Error>
pub fn get_outgoing_receipts_for_shard(
&mut self,
runtime_adapter: &dyn RuntimeAdapter,
prev_block_hash: CryptoHash,
shard_id: ShardId,
last_included_height: BlockHeight
) -> Result<Vec<Receipt>, Error>
Get outgoing receipts that will be sent from shard shard_id
from block whose prev block
is prev_block_hash
Note that the meaning of outgoing receipts here are slightly different from
save_outgoing_receipts
or get_outgoing_receipts
.
There, outgoing receipts for a shard refers to receipts that are generated
from the shard from block prev_block_hash
.
Here, outgoing receipts for a shard refers to receipts that will be sent from this shard
to other shards in the block after prev_block_hash
The difference of one block is important because shard layout may change between the previous
block and the current block and the meaning of shard_id
will change.
Note, the current way of implementation assumes that at least one chunk is generated before shard layout are changed twice. This is not a problem right now because we are changing shard layout for the first time for simple nightshade and generally not a problem if shard layout changes very rarely. But we need to implement a more theoretically correct algorithm if shard layouts will change more often in the future https://github.com/near/nearcore/issues/4877
pub fn check_transaction_validity_period(
&mut self,
prev_block_header: &BlockHeader,
base_block_hash: &CryptoHash,
validity_period: BlockHeight
) -> Result<(), InvalidTxError>
pub fn check_transaction_validity_period(
&mut self,
prev_block_header: &BlockHeader,
base_block_hash: &CryptoHash,
validity_period: BlockHeight
) -> Result<(), InvalidTxError>
For a given transaction, it expires if the block that the chunk points to is more than validity_period
ahead of the block that has base_block_hash
.
pub fn get_outcomes_by_id(
&self,
id: &CryptoHash
) -> Result<Vec<ExecutionOutcomeWithIdAndProof>, Error>
pub fn get_outcomes_by_id(
&self,
id: &CryptoHash
) -> Result<Vec<ExecutionOutcomeWithIdAndProof>, Error>
Returns all outcomes generated by applying transaction or receipt with the given id.
pub fn get_outcomes_by_block_hash_and_shard_id(
&self,
block_hash: &CryptoHash,
shard_id: ShardId
) -> Result<Vec<CryptoHash>, Error>
pub fn get_outcomes_by_block_hash_and_shard_id(
&self,
block_hash: &CryptoHash,
shard_id: ShardId
) -> Result<Vec<CryptoHash>, Error>
Returns a vector of Outcome ids for given block and shard id
Returns a hashmap of epoch id -> set of all blocks got for current (height, epoch_id)
Returns a HashSet of Chunk Hashes for current Height
pub fn get_all_header_hashes_by_height(
&mut self,
height: BlockHeight
) -> Result<HashSet<CryptoHash>, Error>
pub fn get_all_header_hashes_by_height(
&mut self,
height: BlockHeight
) -> Result<HashSet<CryptoHash>, Error>
Returns a HashSet of Header Hashes for current Height
pub fn get_state_header(
&mut self,
shard_id: ShardId,
block_hash: CryptoHash
) -> Result<ShardStateSyncResponseHeader, Error>
Returns latest known height and time it was seen.
Save the latest known.
pub fn get_state_changes_in_block(
&self,
block_hash: &CryptoHash
) -> Result<StateChangesKinds, Error>
pub fn get_state_changes_in_block(
&self,
block_hash: &CryptoHash
) -> Result<StateChangesKinds, Error>
Retrieve the kinds of state changes occurred in a given block.
We store different types of data, so we prefer to only expose minimal information about the changes (i.e. a kind of the change and an account id).
pub fn get_state_changes_with_cause_in_block(
&self,
block_hash: &CryptoHash
) -> Result<StateChanges, Error>
pub fn get_state_changes(
&self,
block_hash: &CryptoHash,
state_changes_request: &StateChangesRequest
) -> Result<StateChanges, Error>
pub fn get_state_changes(
&self,
block_hash: &CryptoHash,
state_changes_request: &StateChangesRequest
) -> Result<StateChanges, Error>
Retrieve the key-value changes from the store and decode them appropriately.
We store different types of data, so we need to take care of all the types. That is, the account data and the access keys are internally-serialized and we have to deserialize those values appropriately. Code and data changes are simple blobs of data, so we return them as base64-encoded blobs.
Trait Implementations
The chain Chunks Tail height, used by GC.
Header of the block at the head of the block chain (not the same thing as header_head).
Largest height for which we created a doomslug endorsement
Head of the header chain (not the same thing as head_header).
Final head of the chain.
fn get_partial_chunk(
&mut self,
chunk_hash: &ChunkHash
) -> Result<&PartialEncodedChunk, Error>
fn get_partial_chunk(
&mut self,
chunk_hash: &ChunkHash
) -> Result<&PartialEncodedChunk, Error>
Get partial chunk.
Does this full block exist?
Get previous header.
Information from applying block.
fn get_chunk_extra(
&mut self,
block_hash: &CryptoHash,
shard_uid: &ShardUId
) -> Result<&ChunkExtra, Error>
fn get_chunk_extra(
&mut self,
block_hash: &CryptoHash,
shard_uid: &ShardUId
) -> Result<&ChunkExtra, Error>
Information from applying chunk.
Get block header.
Returns hash of the block on the main chain for given height.
Get outgoing receipts generated from shard shard_id
in block prev_hash
Note that this function is different from get_outgoing_receipts_for_shard, see comments there
fn get_epoch_light_client_block(
&mut self,
hash: &CryptoHash
) -> Result<&LightClientBlockView, Error>
Returns a number of references for Block with block_hash
fn get_any_chunk_hash_by_height_shard(
&mut self,
height: BlockHeight,
shard_id: ShardId
) -> Result<&ChunkHash, Error>
fn get_any_chunk_hash_by_height_shard(
&mut self,
height: BlockHeight,
shard_id: ShardId
) -> Result<&ChunkHash, Error>
Check if we saw chunk hash at given height and shard id.
fn get_incoming_receipts(
&mut self,
block_hash: &CryptoHash,
shard_id: ShardId
) -> Result<&Vec<ReceiptProof>, Error>
Returns whether the block with the given hash was challenged
fn is_invalid_chunk(
&mut self,
chunk_hash: &ChunkHash
) -> Result<Option<&EncodedShardChunk>, Error>
fn is_invalid_chunk(
&mut self,
chunk_hash: &ChunkHash
) -> Result<Option<&EncodedShardChunk>, Error>
Returns encoded chunk if it’s invalid otherwise None.
Get destination shard id for receipt id.
For a given block and a given shard, get the next block hash where a new chunk for the shard is included.
fn get_last_block_with_new_chunk(
&mut self,
shard_id: u64
) -> Result<Option<&CryptoHash>, Error>
fn get_transaction(
&mut self,
tx_hash: &CryptoHash
) -> Result<Option<&SignedTransaction>, Error>
fn get_block_merkle_tree(
&mut self,
block_hash: &CryptoHash
) -> Result<&PartialMerkleTree, Error>
fn get_block_hash_from_ordinal(
&mut self,
block_ordinal: NumBlocks
) -> Result<&CryptoHash, Error>
fn get_chunk_clone_from_header(
&mut self,
header: &ShardChunkHeader
) -> Result<ShardChunk, Error>
fn get_chunk_clone_from_header(
&mut self,
header: &ShardChunkHeader
) -> Result<ShardChunk, Error>
Get full chunk from header, with possible error that contains the header for further retrieval.
Returns hash of the first available block after genesis.
Returns block header from the current chain for given height if present.
fn get_header_on_chain_by_height(
&mut self,
sync_hash: &CryptoHash,
height: BlockHeight
) -> Result<&BlockHeader, Error>
fn get_header_on_chain_by_height(
&mut self,
sync_hash: &CryptoHash,
height: BlockHeight
) -> Result<&BlockHeader, Error>
Returns block header from the current chain defined by sync_hash
for given height if present.
fn get_block_merkle_tree_from_ordinal(
&mut self,
block_ordinal: NumBlocks
) -> Result<&PartialMerkleTree, Error>
fn get_epoch_id_of_last_block_with_chunk(
&mut self,
runtime_adapter: &dyn RuntimeAdapter,
hash: &CryptoHash,
shard_id: ShardId
) -> Result<EpochId, Error>
fn get_epoch_id_of_last_block_with_chunk(
&mut self,
runtime_adapter: &dyn RuntimeAdapter,
hash: &CryptoHash,
shard_id: ShardId
) -> Result<EpochId, Error>
Get epoch id of the last block with existing chunk for the given shard id.
Auto Trait Implementations
impl !RefUnwindSafe for ChainStore
impl Send for ChainStore
impl Sync for ChainStore
impl Unpin for ChainStore
impl !UnwindSafe for ChainStore
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V
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