aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/Merkle.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-10-24 03:35:20 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-10-24 03:51:08 +0000
commit8c2f0db7337328570af57461a3d95203537ac185 (patch)
treedf90400d4719ab5c04fb84530a8a3c0e2eae213e /lib/kernel/Merkle.ml
parentdf6c0744dc4ebd164cd8a309eef5d2798b2d3e90 (diff)
downloadRNT-8c2f0db7337328570af57461a3d95203537ac185.tar.gz
RNT-8c2f0db7337328570af57461a3d95203537ac185.zip
Use finger trees in more places
Diffstat (limited to 'lib/kernel/Merkle.ml')
-rw-r--r--lib/kernel/Merkle.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/kernel/Merkle.ml b/lib/kernel/Merkle.ml
index c64a9a3..714f5ba 100644
--- a/lib/kernel/Merkle.ml
+++ b/lib/kernel/Merkle.ml
@@ -30,6 +30,7 @@ module type TREE = functor (S : Abstract.Storage.STORAGE) (K : KEY) -> sig
S.transaction -> K.t -> address -> node -> (node, Concepts.Condition.condition) result
val of_list : S.transaction -> (K.t * address) list -> (node, Concepts.Condition.condition) result
+ val of_finger_tree : S.transaction -> (K.t * address) BatFingerTree.t -> (node, Concepts.Condition.condition) result
val remove : S.transaction -> K.t -> node -> (node, Concepts.Condition.condition) result
val lookup : S.transaction -> K.t -> node -> (address option, Concepts.Condition.condition) result
@@ -332,6 +333,14 @@ functor
(fun node (key, value) -> insert tx key value node)
empty bindings )
+ let of_finger_tree tx bindings =
+ let open Utilities.Result in
+ with_batch tx (fun () ->
+ let* _ = empty_under tx in
+ Utilities.FingerTree.foldm_left
+ (fun node (key, value) -> insert tx key value node)
+ empty bindings )
+
let rec fold_left tx f acc =
let open Utilities.Result in
function