package tezos-store
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=43723d096307603703a1a89ed1b2eb202b365f5e7824b96b0cbf813b343a6cf7
sha512=b2a637f2e965000d3d49ad85277ca24d6cb07a1a7cf2bc69d296d8b03ad78c3eaa8e21e94b9162e62c2e11649cd03bc845b2a3dafe623b91065df69d47dc8e4f
doc/tezos-store.shared/Tezos_store_shared/Block_repr/index.html
Module Tezos_store_shared.Block_repr
Source
Block representation effectively stored on disk and its accessors.
Type definitions and encodings
type contents = {
header : Tezos_base.TzPervasives.Block_header.t;
operations : Tezos_base.TzPervasives.Operation.t list list;
block_metadata_hash : Tezos_base.TzPervasives.Block_metadata_hash.t option;
operations_metadata_hashes : Tezos_base.TzPervasives.Operation_metadata_hash.t list list option;
}
The type for the effective contents
of a block is its header and the operations
it contains. Their metadata hashes are also present.
type 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 a block's metadata
stored on disk. This representation is tightly linked to Tezos_validation.Block_validation.result
which also has a strong dependency to Tezos_protocol_environment.validation_result
.
Some fields exposed by Tezos_validation.Block_validation.result
are unnecessary hence the lack of direct link.
type block = {
hash : Tezos_base.TzPervasives.Block_hash.t;
contents : contents;
mutable metadata : metadata option;
}
The type for a block
stored on disk.
The hash
of the block is also stored to improve efficiency by not forcing the user to hash the header. This also allows to store fake hashes (e.g. sandbox's genesis blocks) but should be prevented by the API.
The metadata
might not be present. The mutability flag allows users to re-use the same structure to store freshly loaded metadata.
Genesis
val create_genesis_block :
genesis:Tezos_base.TzPervasives.Genesis.t ->
Tezos_base.TzPervasives.Context_hash.t ->
t
create_genesis_block ~genesis context_hash
creates a default genesis block for the given genesis
and its context_hash
that contains metadata.
Encoding for contents
.
Encoding for metadata
.
pp_json
pretty-print a block as JSON.
Accessors
descriptor block
returns the pair (hash x level) of block
.
hash block
returns the stored block
's hash. It is not guaranteed to be the same as Block_header.hash (header block)
(e.g. in sandbox, the genesis block might have a fake hash).
operations block
returns the list of list of operations contained in the block
.
Block header accessors
val operations_metadata_hashes :
t ->
Tezos_base.TzPervasives.Operation_metadata_hash.t list list option
Metadata accessors
val operations_metadata :
metadata ->
Tezos_validation.Block_validation.operation_metadata list list
Utility functions
val check_block_consistency :
?genesis_hash:Tezos_base.TzPervasives.Block_hash.t ->
?pred_block:t ->
t ->
unit Tezos_base.TzPervasives.tzresult Lwt.t
check_block_consistency ?genesis_hash ?pred_block block
checks that the stored data is consistent:
- Does the
hash
stored equals the result ofBlock_header.hash
of its header and, if not, is this the storedgenesis_hash
? - Is the
block
a successor ofpred_block
with regards to its level and its predecessor's hash? - Are the stored operations hashes consistent regarding the stored operations hashes?