package plebeia

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Node_type end

2 Types

type hashed = Node_type.hashed =
  1. | Hashed of Hash.Prefix.t
  2. | Not_Hashed
    (*

    Type used to prove that if a node is hashed then so are its children. The type also provides the hash as a witness.

    *)
type indexed = Node_type.indexed =
  1. | Indexed of Index.t
  2. | Not_Indexed
    (*

    This rule expresses the following invariant : if a node is indexed, then its children are necessarily indexed. Less trivially, if an internal node is not indexed then at least one of its children is not yet indexed. The reason is that we never construct new nodes that just point to only existing nodes. This property guarantees that when we write internal nodes on disk, at least one of the child can be written adjacent to its parent.

    *)
type extender_witness = Node_type.extender_witness =
  1. | Maybe_Extender
  2. | Not_Extender
  3. | Is_Extender
type node = Node_type.node =
  1. | Disk of Index.t * extender_witness
  2. | View of view
  3. | Hash of Hash.t
and view = private Node_type.view =
  1. | Internal of node * node * indexed * hashed
  2. | Bud of node option * indexed * hashed
  3. | Leaf of Value.t * indexed * hashed
  4. | Extender of Segment.t * node * indexed * hashed

view constructors are private. Use _Internal, _Bud, _Leaf, and _Extender functions with runtime invariant checks.

type t = node

2 Constructors with invariant checks

val _Internal : (node * node * indexed * hashed) -> view
val _Bud : (node option * indexed * hashed) -> view
val _Leaf : (Value.t * indexed * hashed) -> view
val _Extender : (Segment.t * node * indexed * hashed) -> view

2 Accessors

val indexed : node -> bool
val index : node -> Index.t option
val hashed : node -> bool
val hash_available : node -> bool
val index_of_view : view -> Index.t option
val hash_prefix_of_view : view -> Hash.Prefix.t option

2 Tools to create Not_Indexed and Not_Hashed nodes

val new_internal : node -> node -> node
val new_bud : node option -> node
val new_leaf : Value.t -> node
val new_extender : Segment.t -> node -> node

2 Loading of nodes

val may_forget : node -> node option

If the node is indexed, forget the details

2 Debug

val pp : Stdlib.Format.formatter -> node -> unit

Pretty printer

2 Mapper

module Mapper = Node_type.Mapper
module Fold = Node_type.Fold
module Fold' = Node_type.Fold'
val hash_of_view : view -> Hash.t option

Returns the hash of the view already loaded. It returns None if the view does not have the hash.

Note that hash_of_view (Extender (_, n, _, Not_Hashed)) = None even when n has its hash loaded.

val hash_of_node : node -> view option * Hash.t option

Random generators

val gen_leaf : t Gen.t
val gen_bud_none : t Gen.t
val gen_bud : int -> t Gen.t

gen_bud depth is a generator of Bud node with about depth sides

val gen_internal : int -> t Gen.t

gen_bud depth is a generator of Internal node with about depth sides

val gen_extender : int -> t Gen.t

gen_bud depth is a generator of Extender node with about depth sides

Node reading from a context

Obtain the view of the node. If the view is not available in the memory, it is loaded from the storage.

val compute_hash : Context.t -> Node_type.node -> Node_type.node * Hash.t

Compute the hash of the node with its view

OCaml

Innovation. Community. Security.