plebeia

Functional storage using Merkle Patricia tree
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library plebeia
Module Plebeia . Context

2 Types

type t = {
storage : Storage.t;
hashcons : Hashcons.t;
node_cache : Index.t Node_cache.t;
stat : Stat.t;
hash : Hash.Hasher.t;
keep_hash : bool;
bytes_per_cell : int;
}
type config = {
bytes_per_cell : int;
hash_func : [ `Blake2B | `Blake3 ];
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.