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;
  8. with_count : bool;
  9. offsets : Node_offsets.t;
}
type config = {
  1. bytes_per_cell : int;
  2. hash_func : [ `Blake2B | `Blake3 ];
  3. bytes_per_hash : int;
  4. with_count : bool;
}

Configuration which affect data file and hashes

val default_config : config
val get_config : t -> config

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

val pp_config : 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 -> ?keep_hash:bool -> config -> 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 -> ?resize_step_bytes:int -> ?keep_hash:bool -> config -> key:Storage.writer_key -> 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_existing_for_read : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?keep_hash:bool -> config -> string -> (t, Error.t) result Lwt.t

Open an existing context storage.

val open_for_write : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?resize_step_bytes:int -> ?keep_hash:bool -> config -> key:Storage.writer_key -> 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 : Format.formatter -> t -> unit

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