package tezos-storage

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Tezos - Versioned, block indexed (key x value) store

Generic interface

module type S = sig ... end
include S
include Tezos_storage_sigs.Context.VIEW with type key = string list and type value = bytes
type t

The type for context views.

type key = string list

The type for context keys.

type value = bytes

The type for context values.

type tree

The type for context trees.

Getters

val mem : t -> key -> bool Lwt.t

mem t k is an Lwt promise that resolves to true iff k is bound to a value in t.

val mem_tree : t -> key -> bool Lwt.t

mem_tree t k is like mem but for trees.

val find : t -> key -> value option Lwt.t

find t k is an Lwt promise that resolves to Some v if k is bound to the value v in t and None otherwise.

val find_tree : t -> key -> tree option Lwt.t

find_tree t k is like find but for trees.

val list : t -> ?offset:int -> ?length:int -> key -> (string * tree) list Lwt.t

list t key is the list of files and sub-nodes stored under k in t. The result order is not specified but is stable.

offset and length are used for pagination.

Setters

val add : t -> key -> value -> t Lwt.t

add t k v is an Lwt promise that resolves to c such that:

  • k is bound to v in c;
  • and c is similar to t otherwise.

If k was already bound in t to a value that is physically equal to v, the result of the function is a promise that resolves to t. Otherwise, the previous binding of k in t disappears.

val add_tree : t -> key -> tree -> t Lwt.t

add_tree is like add but for trees.

val remove : t -> key -> t Lwt.t

remove t k v is an Lwt promise that resolves to c such that:

  • k is unbound in c;
  • and c is similar to t otherwise.

Folding

val fold : ?depth:[ `Eq of int | `Le of int | `Lt of int | `Ge of int | `Gt of int ] -> t -> key -> init:'a -> f:(key -> tree -> 'a -> 'a Lwt.t) -> 'a Lwt.t

fold ?depth t root ~init ~f recursively folds over the trees and values of t. The f callbacks are called with a key relative to root. f is never called with an empty key for values; i.e., folding over a value is a no-op.

Elements are traversed in lexical order of keys.

The depth is 0-indexed. If depth is set (by default it is not), then f is only called when the conditions described by the parameter is true:

  • Eq d folds over nodes and contents of depth exactly d.
  • Lt d folds over nodes and contents of depth strictly less than d.
  • Le d folds over nodes and contents of depth less than or equal to d.
  • Gt d folds over nodes and contents of depth strictly more than d.
  • Ge d folds over nodes and contents of depth more than or equal to d.
module Tree : sig ... end
type context = t
type index

A block-indexed (key x value) store directory.

val init : ?patch_context: (context -> (context, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t) -> ?mapsize:int64 -> ?readonly:bool -> string -> index Lwt.t

Open or initialize a versioned store at a given path.

val close : index -> unit Lwt.t

Close the index. Does not fail when the context is already closed.

val sync : index -> unit Lwt.t

Sync the context with disk. Only useful for read-only instances. Does not fail when the context is not in read-only mode.

val compute_testchain_chain_id : Tezos_crypto.Block_hash.t -> Tezos_crypto.Chain_id.t
val compute_testchain_genesis : Tezos_crypto.Block_hash.t -> Tezos_crypto.Block_hash.t

Accessing and Updating Versions

val restore_integrity : ?ppf:Stdlib.Format.formatter -> index -> (int option, Tezos_error_monad.TzCore.error list) Stdlib.result

restore_integrity ppf index attempts to restore the context integrity of index. Returns None when nothing needs to be fixed and Some n with n the number of entries fixed. If needs be, the progress might be printed via ppf If the context integrity cannot be restored, Failure msg is thrown.

val exists : index -> Tezos_crypto.Context_hash.t -> bool Lwt.t
val checkout : index -> Tezos_crypto.Context_hash.t -> context option Lwt.t
val hash : time:Tezos_base.Time.Protocol.t -> ?message:string -> t -> Tezos_crypto.Context_hash.t
val commit : time:Tezos_base.Time.Protocol.t -> ?message:string -> context -> Tezos_crypto.Context_hash.t Lwt.t
val set_master : index -> Tezos_crypto.Context_hash.t -> unit Lwt.t

Predefined Fields

val remove_test_chain : context -> context Lwt.t
val fork_test_chain : context -> protocol:Tezos_crypto.Protocol_hash.t -> expiration:Tezos_base.Time.Protocol.t -> context Lwt.t
val clear_test_chain : index -> Tezos_crypto.Chain_id.t -> unit Lwt.t
val find_predecessor_block_metadata_hash : context -> Tezos_crypto.Block_metadata_hash.t option Lwt.t
val add_predecessor_block_metadata_hash : context -> Tezos_crypto.Block_metadata_hash.t -> context Lwt.t
val find_predecessor_ops_metadata_hash : context -> Tezos_crypto.Operation_metadata_list_list_hash.t option Lwt.t
val add_predecessor_ops_metadata_hash : context -> Tezos_crypto.Operation_metadata_list_list_hash.t -> context Lwt.t

Context dumping

module Pruned_block : sig ... end
module Block_data : sig ... end
module Protocol_data : sig ... end
val get_protocol_data_from_header : index -> Tezos_base.Block_header.t -> Protocol_data.t Lwt.t
val validate_context_hash_consistency_and_commit : data_hash:Tezos_crypto.Context_hash.t -> expected_context_hash:Tezos_crypto.Context_hash.t -> timestamp:Tezos_base.Time.Protocol.t -> test_chain:Tezos_base.Test_chain_status.t -> protocol_hash:Tezos_crypto.Protocol_hash.t -> message:string -> author:string -> parents:Tezos_crypto.Context_hash.t list -> predecessor_block_metadata_hash:Tezos_crypto.Block_metadata_hash.t option -> predecessor_ops_metadata_hash: Tezos_crypto.Operation_metadata_list_list_hash.t option -> index:index -> bool Lwt.t
val upgrade_0_0_3 : context_dir:string -> (unit, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t
OCaml

Innovation. Community. Security.