Store.BlockThe module for handling block-related operations such as storing and reading data associated to a single block.
type block = tThe type alias for a block.
type metadata = Tezos_store_shared.Block_repr.metadata = {message : string option;max_operations_ttl : int;last_preserved_block_level : Stdlib.Int32.t;block_metadata : Tezos_base.TzPervasives.Bytes.t;operations_metadata : Tezos_validation.Block_validation.operation_metadata list
list;}The type for block's metadata.
equal b1 b2 tests the equality between b1 and b2. Warning only block hashes are compared.
val is_known_valid :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
bool Lwt.tis_known_valid chain_store bh tests that the block bh is known and valid in chain_store (i.e. the block is present in the block store).
val is_known_invalid :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
bool Lwt.tis_known_invalid chain_store bh tests that the block bh is invalid in chain_store (i.e. the block is present in the invalid blocks file).
val is_known_validated :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
bool Lwt.tis_known_validated chain_store bh tests that the block bh is validated in chain_store (i.e. the block is present in the validated block cache).
val is_known :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
bool Lwt.tis_known chain_store bh tests that the block bh is either known valid or known invalid in chain_store.
val is_genesis : chain_store -> Tezos_base.TzPervasives.Block_hash.t -> boolis_genesis chain_store bh tests that the block bh is the genesis initialized in chain_store.
val validity :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
Tezos_base.TzPervasives.Block_locator.validity Lwt.tvalidity chain_store bh computes the Block_locator.validity (Unknown, Known_valid or Known_invalid) for the block bh in chain_store.
val read_block :
chain_store ->
?distance:int ->
Tezos_base.TzPervasives.Block_hash.t ->
block Tezos_base.TzPervasives.tzresult Lwt.tread_block chain_store ?distance bh tries to read in the chain_store the block bh or the predecessing block at the offset distance of bh. By default, distance is 0.
val read_block_opt :
chain_store ->
?distance:int ->
Tezos_base.TzPervasives.Block_hash.t ->
block option Lwt.tread_block_opt chain_store ?distance bh optional version of read_block.
val read_block_by_level :
chain_store ->
int32 ->
block Tezos_base.TzPervasives.tzresult Lwt.tread_block_by_level chain_store level reads in the chain_store the block at level. The block retrieved will be the (level(current_head) - level)-th predecessor of the chain_store's current head.
val read_block_by_level_opt : chain_store -> int32 -> block option Lwt.tread_block_by_level_opt chain_store level optional version of read_block_by_level.
val read_block_metadata :
?distance:int ->
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
metadata option Tezos_base.TzPervasives.tzresult Lwt.tread_block_metadata ?distance chain_store bh reads in the chain_store the metadata associated to the block bh or its distance-th predecessor if given. Returns None otherwise. By default, distance is 0.
Warning If the block is already read, prefer the usage of get_block_metadata which will memoize the result.
val read_block_metadata_opt :
?distance:int ->
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
metadata option Lwt.tread_block_metadata_opt ?distance chain_store bh same as read_block_metadata but returns None in case of errors.
val get_block_metadata :
chain_store ->
block ->
metadata Tezos_base.TzPervasives.tzresult Lwt.tget_block_metadata chain_store block reads in the chain_store the metadata associated to the block. Returns None if the metadata cannot be retrieved. This function also memoize the result in the block structure so subsequent calls will be disk I/O free.
val get_block_metadata_opt : chain_store -> block -> metadata option Lwt.tget_block_metadata_opt chain_store block optional version of get_block_metadata
val read_predecessor :
chain_store ->
block ->
block Tezos_base.TzPervasives.tzresult Lwt.tread_predecessor chain_store block reads in the chain_store the direct predecessor of block. Returns None if it cannot be found.
val read_predecessor_opt : chain_store -> block -> block option Lwt.tread_predecessor_opt chain_store block optional version of read_predecessor.
val read_predecessor_of_hash :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
block Tezos_base.TzPervasives.tzresult Lwt.tread_predecessor_of_hash chain_store bh reads in chain_store the predecessor's block of bh.
val read_ancestor_hash :
chain_store ->
distance:int ->
Tezos_base.TzPervasives.Block_hash.t ->
Tezos_base.TzPervasives.Block_hash.t option Tezos_base.TzPervasives.tzresult
Lwt.tread_ancestor_hash chain_store ~distance bh retrieves in the chain_store the hash of the ancestor of the block bh at distance if it exists. Returns None otherwise.
val read_ancestor_hash_opt :
chain_store ->
distance:int ->
Tezos_base.TzPervasives.Block_hash.t ->
Tezos_base.TzPervasives.Block_hash.t option Lwt.tread_ancestor_hash_opt chain_store ~distance bh same as read_ancestor_hash but returns None on errors.
val read_predecessor_of_hash_opt :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
block option Lwt.tread_ancestor_opt chain_store block optional version of read_ancestor.
val read_validated_block :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
block Tezos_base.TzPervasives.tzresult Lwt.tread_validated_block chain_store bh tries to read in the chain_store's validated block cache the block bh.
val read_validated_block_opt :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
block option Lwt.tread_validated_block_opt chain_store bh optional version of read_validated_block.
val store_block :
chain_store ->
block_header:Tezos_base.TzPervasives.Block_header.t ->
operations:Tezos_base.TzPervasives.Operation.t list list ->
Tezos_validation.Block_validation.result ->
block option Tezos_base.TzPervasives.tzresult Lwt.tstore_block chain_store ~block_header ~operations validation_result stores in chain_store the block with its block_header, operations and validation result. Inconsistent blocks and validation will result in failures. Returns None if the block was already stored. If the block is correctly stored, the newly created block is returned.
If the block was successfully stored, then the block is removed from the validated block cache.
Warning The store will refuse to store blocks with no associated context's commit.
val store_validated_block :
chain_store ->
hash:Tezos_base.TzPervasives.Block_hash.t ->
block_header:Tezos_base.TzPervasives.Block_header.t ->
operations:
Tezos_base.TzPervasives.Operation.t Tezos_base.TzPervasives.trace
Tezos_base.TzPervasives.trace ->
unit Tezos_base.TzPervasives.tzresult Lwt.tstore_validated_block chain_store ~hash ~block_header ~operations stores in chain_store's validated block cache the block with its block_header and operations.
val resulting_context_hash :
chain_store ->
block ->
Tezos_base.TzPervasives.Context_hash.t Tezos_base.TzPervasives.tzresult Lwt.tresulting_context_hash chain_store block returns the resulting context hash of the block. This context depends on the block's protocol associated semantics, i.e., it can either be the one contained in its block header or the stored result of its application.
val context_exn :
chain_store ->
block ->
Tezos_protocol_environment.Context.t Lwt.tcontext_exn chain_store block checkouts the resulting context of the block which may differ from its block header's one depending on the block's associated protocol semantics.
val context_opt :
chain_store ->
block ->
Tezos_protocol_environment.Context.t option Lwt.tcontext_opt chain_store block optional version of context_exn.
val context :
chain_store ->
block ->
Tezos_protocol_environment.Context.t Tezos_base.TzPervasives.tzresult Lwt.tcontext chain_store block error monad version of context_exn.
val context_exists : chain_store -> block -> bool Lwt.tcontext_exists chain_store block tests the existence of the block's commit in the context.
val testchain_status :
chain_store ->
block ->
(Tezos_base.TzPervasives.Test_chain_status.t
* Tezos_base.TzPervasives.Block_hash.t option)
Tezos_base.TzPervasives.tzresult
Lwt.ttestchain_status chain_store block returns the test chain status stored in context of block along with testchain's genesis if the testchain is found Forking or Running.
val protocol_hash_exn :
chain_store ->
block ->
Tezos_base.TzPervasives.Protocol_hash.t Lwt.tprotocol_hash_exn chain_store block reads the protocol associated to block in its associated context. Fails when the context is unknown.
val protocol_hash :
chain_store ->
block ->
Tezos_base.TzPervasives.Protocol_hash.t Tezos_base.TzPervasives.tzresult
Lwt.tprotocol_hash chain_store block error monad version of protocol_hash_exn.
val read_invalid_block_opt :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
Tezos_store_shared.Store_types.invalid_block option Lwt.tread_invalid_block_opt chain_store bh reads in the chain_store the invalid block bh if it exists.
val read_invalid_blocks :
chain_store ->
Tezos_store_shared.Store_types.invalid_block
Tezos_base.TzPervasives.Block_hash.Map.t
Lwt.tread_invalid_blocks chain_store returns the map of all invalid blocks of chain_store.
val mark_invalid :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
level:int32 ->
Tezos_base.TzPervasives.error list ->
unit Tezos_base.TzPervasives.tzresult Lwt.tmark_invalid chain_store bh ~level errors stores the block bh at level with the given errors. Fails when trying to mark the genesis block as invalid.
val unmark_invalid :
chain_store ->
Tezos_base.TzPervasives.Block_hash.t ->
unit Tezos_base.TzPervasives.tzresult Lwt.tunmark_invalid chain_store bh unmarks invalid the block bh in the chain_store.
val descriptor : block -> Tezos_store_shared.Store_types.block_descriptordescriptor block returns the pair (hash x level) of block.
val hash : block -> Tezos_base.TzPervasives.Block_hash.tval header : block -> Tezos_base.TzPervasives.Block_header.tval operations : block -> Tezos_base.TzPervasives.Operation.t list listval shell_header : block -> Tezos_base.TzPervasives.Block_header.shell_headerval level : block -> int32val proto_level : block -> intval predecessor : block -> Tezos_base.TzPervasives.Block_hash.tval timestamp : block -> Tezos_base.TzPervasives.Time.Protocol.tval validation_passes : block -> intval operations_hash :
block ->
Tezos_base.TzPervasives.Operation_list_list_hash.tval fitness : block -> Tezos_base.TzPervasives.Fitness.tval context_hash : block -> Tezos_base.TzPervasives.Context_hash.tval protocol_data : block -> bytesval block_metadata_hash :
block ->
Tezos_base.TzPervasives.Block_metadata_hash.t optionval operations_metadata_hashes :
block ->
Tezos_base.TzPervasives.Operation_metadata_hash.t list list optionval operations_metadata_hashes_path :
block ->
int ->
Tezos_base.TzPervasives.Operation_metadata_hash.t list optionval all_operations_metadata_hash :
block ->
Tezos_base.TzPervasives.Operation_metadata_list_list_hash.t optionval message : metadata -> string optionval max_operations_ttl : metadata -> intval last_preserved_block_level : metadata -> int32val block_metadata : metadata -> Tezos_base.TzPervasives.Bytes.tval operations_metadata :
metadata ->
Tezos_validation.Block_validation.operation_metadata list listval operations_path :
block ->
int ->
Tezos_base.TzPervasives.Operation.t list
* Tezos_base.TzPervasives.Operation_list_list_hash.pathoperations_path block nth computes the nth operations list of block along with the hash of all operations.
val operations_hashes_path :
block ->
int ->
Tezos_base.TzPervasives.Operation_hash.t list
* Tezos_base.TzPervasives.Operation_list_list_hash.pathoperations_hashes_path block nth computes the nth operations hash list of block along with the hash of all operations.
val all_operation_hashes :
block ->
Tezos_base.TzPervasives.Operation_hash.t list listall_operation_hashes block computes the hash of all operations in block.