package tezos-context
Tezos: on-disk context abstraction for `tezos-node`
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-v12.3.tar.bz2
sha256=296bb5674bc6050afe6330326fbdd0dfc2255d414bfd6b79cc7666ac6b39316d
sha512=c061cd300a9410300851158d77bf8e56ca3c568b0b1161b38305e5b2efdcd9c746d391f832fdb2826f9a1d6babce10a9b764a4b04f5df42699f7314b9863123a
doc/src/tezos-context.sigs/context.ml.html
Source file context.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018-2021 Tarides <contact@tarides.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) (** The tree depth of a fold. See the [View.fold] function for more information. *) type depth = [`Eq of int | `Le of int | `Lt of int | `Ge of int | `Gt of int] module type VIEW = sig (** The type for context views. *) type t (** The type for context keys. *) type key (** The type for context values. *) type value (** The type for context trees. *) type tree (** {2 Getters} *) (** [mem t k] is an Lwt promise that resolves to [true] iff [k] is bound to a value in [t]. *) val mem : t -> key -> bool Lwt.t (** [mem_tree t k] is like {!mem} but for trees. *) val mem_tree : t -> key -> bool 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 : t -> key -> value option Lwt.t (** [find_tree t k] is like {!find} but for trees. *) val find_tree : t -> key -> tree option 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. *) val list : t -> ?offset:int -> ?length:int -> key -> (string * tree) list Lwt.t (** {2 Setters} *) (** [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 : t -> key -> value -> t Lwt.t (** [add_tree] is like {!add} but for trees. *) val add_tree : t -> key -> tree -> 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. *) val remove : t -> key -> t Lwt.t (** {2 Folding} *) (** [fold ?depth t root ~order ~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. 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]. If [order] is [`Sorted] (the default), the elements are traversed in lexicographic order of their keys. For large nodes, it is memory-consuming, use [`Undefined] for a more memory efficient [fold]. *) val fold : ?depth:depth -> t -> key -> order:[`Sorted | `Undefined] -> init:'a -> f:(key -> tree -> 'a -> 'a Lwt.t) -> 'a Lwt.t end module Kind = struct type t = [`Value | `Tree] end module type TREE = sig (** [Tree] provides immutable, in-memory partial mirror of the context, with lazy reads and delayed writes. The trees are Merkle trees that carry the same hash as the part of the context they mirror. Trees are immutable and non-persistent (they disappear if the host crash), held in memory for efficiency, where reads are done lazily and writes are done only when needed, e.g. on [Context.commit]. If a key is modified twice, only the last value will be written to disk on commit. *) (** The type for context views. *) type t (** The type for context trees. *) type tree include VIEW with type t := tree and type tree := tree (** [empty _] is the empty tree. *) val empty : t -> tree (** [is_empty t] is true iff [t] is [empty _]. *) val is_empty : tree -> bool (** [kind t] is [t]'s kind. It's either a tree node or a leaf value. *) val kind : tree -> Kind.t (** [to_value t] is an Lwt promise that resolves to [Some v] if [t] is a leaf tree and [None] otherwise. It is equivalent to [find t []]. *) val to_value : tree -> value option Lwt.t (** [of_value _ v] is an Lwt promise that resolves to the leaf tree [v]. Is is equivalent to [add (empty _) [] v]. *) val of_value : t -> value -> tree Lwt.t (** [hash t] is [t]'s Merkle hash. *) val hash : tree -> Context_hash.t (** [equal x y] is true iff [x] and [y] have the same Merkle hash. *) val equal : tree -> tree -> bool (** {2 Caches} *) (** [clear ?depth t] clears all caches in the tree [t] for subtrees with a depth higher than [depth]. If [depth] is not set, all of the subtrees are cleared. *) val clear : ?depth:int -> tree -> unit end module type HASH_VERSION = sig (** The type for context views. *) type t val get_hash_version : t -> Context_hash.Version.t val set_hash_version : t -> Context_hash.Version.t -> t Lwt.t end module type S = sig include VIEW with type key = string list and type value = bytes module Tree : sig include TREE with type t := t and type key := key and type value := value and type tree := tree (** [pp] is the pretty-printer for trees. *) val pp : Format.formatter -> tree -> unit (** {2 Data Encoding} *) (** The type for in-memory, raw contexts. *) type raw = [`Value of bytes | `Tree of raw TzString.Map.t] (** [raw_encoding] is the data encoding for raw trees. *) val raw_encoding : raw Data_encoding.t (** [to_raw t] is an Lwt promise that resolves to a raw tree equivalent to [t]. *) val to_raw : tree -> raw Lwt.t (** [of_raw t] is the tree equivalent to the raw tree [t]. *) val of_raw : raw -> tree (** The type of tree for which to build a shallow tree with [shallow] *) type kinded_hash := [`Contents of Context_hash.t | `Node of Context_hash.t] type repo val make_repo : unit -> repo Lwt.t val shallow : repo -> kinded_hash -> tree end end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>