Functional storage using Merkle Patricia tree
Module type
Class type
Library plebeia
Module Plebeia . Fs_intf . S . Vc
type t = Vc.t

Type of version controller

val create : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?lock:bool -> ?bytes_per_cell:int -> ?hash_func:[ `Blake2B | `Blake3 ] -> ?bytes_per_hash:int -> ?resize_step_bytes:int -> ?auto_flush_seconds:int -> string -> ( t, Error.t ) Result_lwt.t

Create an empty commit store

val open_ : mode:Storage.mode -> ?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 -> ?auto_flush_seconds:int -> string -> ( t, Error.t ) Result_lwt.t

Opens a commit store of the given name if it exists. Otherwise, it creates a new store.

val close : t -> ( unit, Error.t ) Stdlib.result Lwt.t

Close the version control. Once closed, further uses of t are unspecified.

val empty : t -> cursor

Returns a cursor pointing to an empty tree

val of_value : t -> bytes -> cursor

Returns a cursor pointing to a leaf with the value specified by the given bytes

val checkout : t -> Commit_hash.t -> cursor option Lwt.t

Checkout the commit of the given commit hash

val checkout' : t -> Commit_hash.t -> (Commit.t * cursor) option Lwt.t

Same as checkout but returns the commit information together

val mem : t -> Commit_hash.t -> bool Lwt.t

Check the given commit hash is known

val compute_commit_hash : t -> parent:Commit_hash.t option -> cursor -> cursor * Commit_hash.t

Compute the commit hash for the root of the current tree. The cursor is moved to the root.

Note that the commit hash is NOT the top Merkle hash of the cursor. It is computed from the top Merkle hash and the parent commit hash

val commit : ?allow_missing_parent:bool -> t -> parent:Commit_hash.t option -> hash_override:Commit_hash.t option -> (Hash.Prefix.t * Commit.t) Op_lwt.t

Commit the contents of the cursor at the root. It then returns the updated cursor, the hash, and the commit information.

If override is false (by default), hash collision fails the function. If it is true, it overwrites the hash.

The commit will be persisted to the disk eventually, but may be lost if the program crashes. To make it surely persisted, sync must be called explicitly.

val flush : t -> unit Lwt.t

Synchronize the commits to the disk. Commits after the last call of this flush may be lost when the program crashes.

Too frequent call of this function may slow down the system.

val commit_db : t -> Commit_db.t

Underlying commit database

val context : t -> Context.t

Underlying context