Functional storage using Merkle Patricia tree
Module type
Class type
Library plebeia
Module Plebeia . Commit_tree
type entry = {
parent : Commit_hash.t option;
index : Index.t;(*

The index in the context for Commit.t

type t
val create : ?length:Index.t -> ?resize_step_bytes:int -> string -> t Lwt.t

Create a new empty commit tree file

val open_ : ?resize_step_bytes:int -> mode:Storage.mode -> string -> t option Lwt.t

If the file exists, load its latest commit tree. Otherwise, returns None

val offline_gc : ?resize_step_bytes:int -> string -> ( unit, Error.t ) Stdlib.result Lwt.t

gc fn replaces the commit tree file fn by a new one only with the latest commit found in fn.

The original file is backed up as fn ^ ".old". If the backup file already exists, it is overwritten.

This GC is offline. Never call this function when fn is being used.

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

Write the modifications to t to the disk.

val commit : t -> unit Lwt.t
val flush : t -> unit Lwt.t
val update_reader : t -> t Lwt.t

Update t to the latest commit tree on the disk.

The reader process of the commit tree must call this function time to time to get the updates by the writer.

val may_forget : t -> t option

Forget the on-memory cache of t. This fails and returns None if t has unsaved updates.

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

Close t.

In Writer mode, it saves before closing. Save errors do not prevent the closing.

val mode : t -> Storage.mode
val mem : t -> Commit_hash.t -> bool
val find : t -> Commit_hash.t -> entry option
val add : t -> Commit_hash.t -> entry -> t

If a binding already exists, it is overwritten.

val fold : ( Commit_hash.t -> entry -> 'a -> 'a Lwt.t ) -> t -> 'a -> 'a Lwt.t
val iter : ( Commit_hash.t -> entry -> unit Lwt.t ) -> t -> unit Lwt.t
val children : t -> ( Commit_hash.t -> (Commit_hash.t * entry) list ) Lwt.t

children t returns a function to query children of the given hash.

Note that children t takes some time since it traverses the whole commit tree.

val geneses : t -> (Commit_hash.t * entry) list Lwt.t

Get the genesis commit hashes and the entries, which have no parent.

This function traverses the whole commit tree, therefore inefficient.

val ordered_fold : ( Commit_hash.t -> entry -> children:(Commit_hash.t * entry) list -> 'a -> 'a Lwt.t ) -> t -> 'a -> 'a Lwt.t

Folding. Parent commits are folded earlier than their children

Note that ordered_fold takes some time since it traverse the whole commit tree.

module Internal : sig ... end

test and debugging purpose