aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/Multigroup.ml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/kernel/Multigroup.ml14
-rw-r--r--lib/kernel/Multigroup.mli10
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/kernel/Multigroup.ml b/lib/kernel/Multigroup.ml
index 1417a65..ecc871e 100644
--- a/lib/kernel/Multigroup.ml
+++ b/lib/kernel/Multigroup.ml
@@ -21,9 +21,9 @@ module Make (S : Abstract.Storage.STORAGE) = struct
Stored.of_bencode data |> Result.map (fun relation -> Ephemeral relation)
| _ -> R.Representation.of_bencode data |> Result.map (fun relation -> Substantial relation)
- let load storage = function
+ let load ?bind storage = function
| Substantial relation -> R.load storage relation
- | Ephemeral relation -> E.load storage relation
+ | Ephemeral relation -> E.load ?bind storage relation
end
module RelationM = Merkle.Interface (S) (Merkle.StringKey) (Entry)
@@ -71,7 +71,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct
let encode = Representation.to_blob
let decode = Representation.of_blob
- class multigroup conn value node =
+ class multigroup ?bind conn value node =
object (self)
inherit Lifecycle.null
method to_string = "multigroup"
@@ -91,7 +91,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct
RelationM.find tx multigroup'.relations
|> fmap (Option.to_result ~none:(Error.incomplete_multigroup multigroup'.relations)) )
in
- new multigroup storage multigroup' node' |> Protocols.Handle.make |> Result.ok
+ new multigroup ?bind storage multigroup' node' |> Protocols.Handle.make |> Result.ok
method protocols : Protocols.Handle.protocol list =
let open Utilities.Result in
@@ -108,7 +108,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct
[ ( "relation",
Prototype.mixture_of node (fun make node ->
[ RMAddressable.make ~node:(RelationM.into node);
- RMDirectory.make ~storage ~node ~constructor:(Entry.load storage);
+ RMDirectory.make ~storage ~node ~constructor:(Entry.load ?bind storage);
RMAssociative.make ~storage ~node:(RelationM.into node)
~constructor:(fun node' -> RelationM.from node' |> make |> Result.ok ) ] )
) ] ]
@@ -117,13 +117,13 @@ module Make (S : Abstract.Storage.STORAGE) = struct
method address = self#hash
end
- let wrap conn value =
+ let wrap ?bind conn value =
let open Utilities.Result in
let* node =
SI.with_transaction conn (fun tx -> RelationM.find tx value.relations)
|> fmap (Option.to_result ~none:(Error.incomplete_multigroup value.relations))
in
- new multigroup conn value node |> Protocols.Handle.make |> Result.ok
+ new multigroup ?bind conn value node |> Protocols.Handle.make |> Result.ok
let make conn =
let open Utilities.Result in
diff --git a/lib/kernel/Multigroup.mli b/lib/kernel/Multigroup.mli
index 2df41e6..f8e2555 100644
--- a/lib/kernel/Multigroup.mli
+++ b/lib/kernel/Multigroup.mli
@@ -3,6 +3,14 @@ module Make (S : Abstract.Storage.STORAGE) : sig
val encode : t -> Concepts.Blob.t
val decode : Concepts.Blob.t -> (t, Concepts.Condition.condition) result
- val wrap : S.connection -> t -> (Protocols.Handle.t, Concepts.Condition.condition) result
+
+ (** [bind] runs the stored programs read through the multigroup; see
+ [EphemeralRelation.binding]. *)
+ val wrap :
+ ?bind:EphemeralRelation.binding ->
+ S.connection ->
+ t ->
+ (Protocols.Handle.t, Concepts.Condition.condition) result
+
val make : S.connection -> (Protocols.Handle.t, Concepts.Condition.condition) result
end