package tezos-store
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/tezos-store.unix/Tezos_store_unix/Store/Block/index.html
Module Store.Block
Source
The module for handling block-related operations such as storing and reading data associated to a single block.
The abstract type for a block.
type metadata = Tezos_store_shared.Block_repr.metadata = {
message : string option;
max_operations_ttl : int;
last_allowed_fork_level : 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.
is_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).
is_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).
is_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).
is_known chain_store bh
tests that the block bh
is either known valid or known invalid in chain_store
.
is_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.t
validity 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.t
read_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.t
read_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.t
read_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.
read_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.t
read_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.t
read_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.t
get_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.
get_block_metadata_opt chain_store block
optional version of get_block_metadata
read_predecessor chain_store block
reads in the chain_store
the direct predecessor of block
. Returns None
if it cannot be found.
read_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.t
read_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.t
read_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.t
read_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.t
read_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.t
read_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.t
read_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.t
store_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.
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.t
store_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.t
resulting_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.
context_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.
context_opt chain_store block
optional version of context_exn
.
val context :
chain_store ->
block ->
Tezos_protocol_environment.Context.t Tezos_base.TzPervasives.tzresult Lwt.t
context chain_store block
error monad version of context_exn
.
context_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.t
testchain_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
.
protocol_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.t
protocol_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.t
read_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.t
read_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.t
mark_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.t
unmark_invalid chain_store bh
unmarks invalid the block bh
in the chain_store
.
descriptor block
returns the pair (hash x level) of block
.
Block field accessors
val operations_metadata_hashes :
block ->
Tezos_base.TzPervasives.Operation_metadata_hash.t list list option
val operations_metadata_hashes_path :
block ->
int ->
Tezos_base.TzPervasives.Operation_metadata_hash.t list option
val all_operations_metadata_hash :
block ->
Tezos_base.TzPervasives.Operation_metadata_list_list_hash.t option
Block metadata field accessors
val operations_metadata :
metadata ->
Tezos_validation.Block_validation.operation_metadata list list
val operations_path :
block ->
int ->
Tezos_base.TzPervasives.Operation.t list
* Tezos_base.TzPervasives.Operation_list_list_hash.path
operations_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.path
operations_hashes_path block nth
computes the nth
operations hash list of block
along with the hash of all operations.
all_operation_hashes block
computes the hash of all operations in block
.