package plebeia

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

1 Merkle Patricia tree storage

2 Types

type t = {
  1. storage : Storage.t;
  2. hashcons : Hashcons.t;
  3. node_cache : Index.t Node_cache.t;
  4. stat : Stat.t;
  5. hash : Hash.Hasher.t;
  6. keep_hash : bool;
  7. bytes_per_cell : int;
}
type config = {
  1. bytes_per_cell : int;
  2. hash_func : [ `Blake2B | `Blake3 ];
  3. bytes_per_hash : int;
}

Configuration which affect data file and hashes

val get_config : t -> config

Build the config. Do not call it in busy loops since it allocates a record

val pp_config : Stdlib.Format.formatter -> config -> unit
val config_name : config -> string

Short string to identify configs

val get_storage : t -> Storage.t
val memory_only : ?hashcons:Hashcons.config -> ?bytes_per_cell:int -> ?hash_func:[ `Blake2B | `Blake3 ] -> ?bytes_per_hash:int -> ?keep_hash:bool -> unit -> t

Create a memory_only context.

Commiting nodes of a memory only context fails.

val is_memory_only : t -> bool
val create : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?bytes_per_cell:int -> ?hash_func:[ `Blake2B | `Blake3 ] -> ?bytes_per_hash:int -> ?resize_step_bytes:int -> ?keep_hash:bool -> string -> t Lwt.t

Create a new context storage. Note that if the file already exists, create fails.

The context is created in Writer mode.

length: initial size of the file in bytes

val open_ : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> mode:Storage.mode -> ?bytes_per_cell:int -> ?hash_func:[ `Blake2B | `Blake3 ] -> ?bytes_per_hash:int -> ?resize_step_bytes:int -> ?keep_hash:bool -> string -> t Lwt.t

Open an existing context storage.

val close : t -> unit Lwt.t

Closes the context.

If program exits or crashes without closing a context, some data may be lost, even if they are written on the disk.

val mode : t -> Storage.mode

Returns writing mode

val shrink_node_cache : t -> unit

Shrink the node cache

val pp_cache_for_debug : Stdlib.Format.formatter -> t -> unit

It runs Obj.reachable_words which takes long time. Do not use in production.

OCaml

Innovation. Community. Security.