aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/Storage.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-08-13 00:22:02 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-08-23 03:06:54 +0000
commita727eb4351df972ff2e34fa111aeb435e70cdbd4 (patch)
tree897531a4f085aef5a96fb4b91bc631e8c5a6cc0d /lib/kernel/Storage.ml
parent634625d832873b75b3d9c049db2e95fda31135ae (diff)
downloadRNT-a727eb4351df972ff2e34fa111aeb435e70cdbd4.tar.gz
RNT-a727eb4351df972ff2e34fa111aeb435e70cdbd4.zip
Move storage helpers to a dedicated module
Diffstat (limited to 'lib/kernel/Storage.ml')
-rw-r--r--lib/kernel/Storage.ml22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/kernel/Storage.ml b/lib/kernel/Storage.ml
new file mode 100644
index 0000000..952b306
--- /dev/null
+++ b/lib/kernel/Storage.ml
@@ -0,0 +1,22 @@
+module Make (S : Abstract.Storage.STORAGE) = struct
+ let finish tx = function
+ | Ok value ->
+ let open Utilities.Result in
+ let* () = S.commit tx in
+ Ok value
+ | Error condition ->
+ let _ = S.abort tx in
+ Error condition
+
+ let with_transaction connection body =
+ let open Utilities.Result in
+ let* tx = S.start connection in
+ body tx |> finish tx
+
+ let store_blob tx blob =
+ let open Utilities.Result in
+ let address = Concepts.Hash.hash_of_blob blob in
+ let* () = S.put tx address blob in
+ Ok address
+
+end