diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-08-23 03:52:08 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-08-23 03:52:08 +0000 |
| commit | 8f87d272038ddea11c366d9a14079666daf6628b (patch) | |
| tree | bbecb53f35452cc3caecf6fb85994629d67ce3af /lib/kernel | |
| parent | 1d0b73b051cff4b14919808c51acbdd1c3e11767 (diff) | |
| download | RNT-8f87d272038ddea11c366d9a14079666daf6628b.tar.gz RNT-8f87d272038ddea11c366d9a14079666daf6628b.zip | |
The branch manager should persist changes to the root
Diffstat (limited to 'lib/kernel')
| -rw-r--r-- | lib/kernel/BranchManager.ml | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/kernel/BranchManager.ml b/lib/kernel/BranchManager.ml index a698a87..bdc461e 100644 --- a/lib/kernel/BranchManager.ml +++ b/lib/kernel/BranchManager.ml @@ -26,6 +26,10 @@ module Make (S : Abstract.Storage.STORAGE) = struct let label = Option.map Concepts.Hash.hash_of_blob label in Ok label + let persist_root tx label addr = + let data = Concepts.Hash.blob_of_hash addr in + S.put tx (S.Label label) data + class manager storage label head = object (self) inherit Lifecycle.null @@ -46,6 +50,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct |> fmap (Option.to_result ~none:(Error.no_such_branch branch_name)) in if branch = reference then let* new_head = M.insert tx label new_branch head in + let* _ = persist_root tx label (M.hash_of new_head) in Ok new_head else Error (Error.branch_head_mismatch branch_name reference branch))) @@ -63,7 +68,8 @@ module Make (S : Abstract.Storage.STORAGE) = struct SI.with_transaction storage (fun tx -> let* addr = root_for tx label in match addr with - | None -> failwith "TODO" + | None -> + Ok (new manager storage label M.empty |> Protocols.Handle.make) | Some addr -> let* head = M.find tx addr in let* head = Option.to_result ~none:(Error.invalid_root addr) head in |
