From ab360c794849300792b2dc5c9ff6354621040e2f Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sat, 1 Aug 2026 14:22:05 -0300 Subject: Initialization with Branch State and Index --- lib/kernel/BranchIndex.ml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/kernel/BranchIndex.ml (limited to 'lib/kernel/BranchIndex.ml') diff --git a/lib/kernel/BranchIndex.ml b/lib/kernel/BranchIndex.ml new file mode 100644 index 0000000..d1efa9a --- /dev/null +++ b/lib/kernel/BranchIndex.ml @@ -0,0 +1,29 @@ +type address = Concepts.Hash.hash +type root = address +type branch_name = string +type branch_state_root = address + +let default_branch_name = "master" + +module Branch_name = struct + type t = branch_name + + let encode name = Concepts.Codec.Bencode.(String name |> to_blob) + let compare left right = Concepts.Ordering.of_int (String.compare left right) + + let decode blob = + Concepts.Codec.Bencode.of_blob blob |> Utilities.Result.fmap Concepts.Codec.Bencode.as_string +end + +module Make (Store : Abstract.Storage.STORAGE) = struct + module Tree = Merkle.Make (Store) (Branch_name) + + type tree = Tree.node + + let empty = Tree.empty + let hash_of = Tree.hash_of + let persist = Tree.persist + let find = Tree.find + let find_branch = Tree.lookup + let put_branch = Tree.insert +end -- cgit v1.2.3