diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-10-01 00:21:31 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-10-01 00:21:31 -0300 |
| commit | c824f42518a1963ba2d895a9944bf4d885114eab (patch) | |
| tree | 5e9e172e9727404ad42abd490ec3b77f972f2cd5 /lib/kernel/SubstantialRelation.ml | |
| parent | 2752f7aeba9b6cef774783ba0a54c2025a3d692b (diff) | |
| download | RNT-c824f42518a1963ba2d895a9944bf4d885114eab.tar.gz RNT-c824f42518a1963ba2d895a9944bf4d885114eab.zip | |
ephemeral and substantial relation storage routing
Diffstat (limited to 'lib/kernel/SubstantialRelation.ml')
| -rw-r--r-- | lib/kernel/SubstantialRelation.ml | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/kernel/SubstantialRelation.ml b/lib/kernel/SubstantialRelation.ml index 844b186..57bb79e 100644 --- a/lib/kernel/SubstantialRelation.ml +++ b/lib/kernel/SubstantialRelation.ml @@ -74,9 +74,17 @@ module Make (S : Abstract.Storage.STORAGE) = struct let* tuples = TupleSet.find tx relation.tuples in Option.to_result ~none:(Error.invalid_tuple_root relation.tuples) tuples - let schema_of tx relation = + let store_schema tx description = + Concepts.Encoding.Bencode.( + Dict + ( BatMap.String.bindings description + |> List.map (fun (name, {Protocols.Schematics.domain; _}) -> name, String domain) ) + |> to_blob ) + |> SI.store_blob tx + + let schema_of tx schematics = let open Utilities.Result in - let* data = SI.get_req tx (S.Hash relation.schematics) in + let* data = SI.get_req tx (S.Hash schematics) in let* fields = Concepts.Encoding.Bencode.of_blob data in let* kvs = Concepts.Encoding.Bencode.as_dict fields in kvs @@ -112,15 +120,17 @@ module Make (S : Abstract.Storage.STORAGE) = struct method enumerate = enumerate connection relation method protocols : Protocols.Handle.protocol list = - [ Protocols.Relation.make self; + [ Protocols.Addressable.make self; + Protocols.Relation.make self; Protocols.Enumerable.make self; Protocols.Schematics.make self ] method hash = encode relation |> Concepts.Hash.hash_of_blob + method address = self#hash end let load connection relation = - SI.with_read connection (fun tx -> schema_of tx relation) + SI.with_read connection (fun tx -> schema_of tx relation.schematics) |> Result.map (fun description -> new substantial_relation connection relation description |> Protocols.Handle.make ) |
