diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-09-03 02:23:27 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-09-03 02:23:51 +0000 |
| commit | 1259773fac4d7c334351c61ab8cf71231c1af4ef (patch) | |
| tree | 941d59334c04c1f4794ef16e4904cb7dafaa6b72 /lib/kernel/Branch.ml | |
| parent | cad153992e5ead450ae8245e518c6c88fe778ac1 (diff) | |
| download | RNT-1259773fac4d7c334351c61ab8cf71231c1af4ef.tar.gz RNT-1259773fac4d7c334351c61ab8cf71231c1af4ef.zip | |
Branch registration
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/Branch.ml | 24 | ||||
| -rw-r--r-- | lib/kernel/Branch.mli | 3 |
2 files changed, 23 insertions, 4 deletions
diff --git a/lib/kernel/Branch.ml b/lib/kernel/Branch.ml index 2aaa9ca..31442f6 100644 --- a/lib/kernel/Branch.ml +++ b/lib/kernel/Branch.ml @@ -52,9 +52,27 @@ module Make (S : Abstract.Storage.STORAGE) = struct Ok { multigroups; previous } end - class branch = object - (* TODO *) + class branch storage value = object + inherit Lifecycle.null + + val storage : S.connection = storage + val branch : t = value + + method protocols : Protocols.Handle.protocol list = [] + + method hash = + Representation.to_blob branch + |> Concepts.Hash.hash_of_blob end - let load _tx _conn _name _addr = failwith "TODO" + let load tx conn addr = + let open Utilities.Result in + let* data = SI.get_req tx (S.Hash addr) in + let* branch = Representation.of_blob data in + Ok (new branch conn branch |> Protocols.Handle.make) + + let make conn = + let open Utilities.Result in + let* empty = SI.with_transaction conn MultigroupM.empty_under in + Ok (new branch conn { multigroups = empty; previous = None } |> Protocols.Handle.make) end diff --git a/lib/kernel/Branch.mli b/lib/kernel/Branch.mli index 02be2ed..82bdbb7 100644 --- a/lib/kernel/Branch.mli +++ b/lib/kernel/Branch.mli @@ -1,5 +1,6 @@ module Make (S : Abstract.Storage.STORAGE) : sig type t - val load : S.transaction -> S.connection -> string -> Concepts.Hash.hash -> (Protocols.Handle.t, Concepts.Condition.condition) result + val make : S.connection -> (Protocols.Handle.t, Concepts.Condition.condition) result + val load : S.transaction -> S.connection -> Concepts.Hash.hash -> (Protocols.Handle.t, Concepts.Condition.condition) result end |
