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

Type of the version control handle

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.

hashcons: Hashcons configuration node_cache: Node_cache configuration lock: Aquire a lock when true byte_per_cell: The width of the Plebeia cell hash_func: Hashing algorithm bytes_per_hash: Hash width resize_step_bytes: How much additional disk space is allocated each time when the system finds the file is full. auto_flush_seconds: How often automatically flush the additions to the disk at commit in seconds.

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.

mode: Opening mode.

See create for the other parameters.

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

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

val enable_process_sync : t -> unit

For readers, enable the process sync. See Storage.enable_process_sync

val empty : t -> Cursor.t
val commit_db : t -> Commit_db.t
val context : t -> Context.t
val checkout : ?keep_info:bool -> t -> Commit_hash.t -> Cursor.t option Lwt.t

Checkout the commit of the given commit hash

val checkout' : ?keep_info:bool -> t -> Commit_hash.t -> (Commit.t * Cursor.t) 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.t -> Cursor.t * 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 -> Cursor.t -> ( Cursor.t * Hash.Prefix.t * Commit.t, Error.t ) Stdlib.result Lwt.t

Commit the contents of the cursor, then returns the updated cursor at the top, 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 may be lost if the program crashes. To make it surely persisted, call flush explicitly or set auto_flush_seconds.

val flush : t -> unit Lwt.t

Flush the commits already done to the disk. The commits before the last flush call are persisted even after a system crash.

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