diff options
Diffstat (limited to 'lib/kernel/SubstantialRelation.ml')
| -rw-r--r-- | lib/kernel/SubstantialRelation.ml | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/kernel/SubstantialRelation.ml b/lib/kernel/SubstantialRelation.ml index 193df98..e89b008 100644 --- a/lib/kernel/SubstantialRelation.ml +++ b/lib/kernel/SubstantialRelation.ml @@ -61,7 +61,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct end module TupleSet = Merkle.Interface (S) (TupleKey) (TupleValue) - module Index = Merkle.Make (S) (Merkle.StringKey) + module Index = Merkle.Interface (S) (Merkle.StringKey) (TupleValue) type t = { schematics: Concepts.Hash.hash; @@ -150,19 +150,15 @@ module Make (S : Abstract.Storage.STORAGE) = struct BatMap.String.find_opt attribute relation.indexes |> Option.to_result ~none:(Error.unindexed_attribute attribute) in - let prefix = prefix value in + let start = prefix value in reading connection (fun tx -> Index.find tx root |>> Option.to_result ~none:(Error.invalid_index_root root)) (fun tx node ~yield -> - Index.fold_left ~from:prefix - ~until:(fun key -> not (String.starts_with ~prefix key)) + Index.fold_left ~from:start + ~until:(fun key -> not (String.starts_with ~prefix:start key)) tx - (fun read _ address -> - let* () = read in - let* tuple = SI.get_req tx (S.Hash address) |>> TupleValue.decode in - Ok (yield tuple) ) - (Ok ()) node - |> Result.join ) + (fun () _ tuple -> yield tuple) + () node ) class substantial_relation connection value description = object (self) @@ -223,8 +219,8 @@ module Make (S : Abstract.Storage.STORAGE) = struct ^ Concepts.Hash.to_raw_string hash, hash ) ) hashed - |> Index.of_list tx - |> Result.map (fun node -> attribute, Index.hash_of node) + |> Index.Tree.of_list tx + |> Result.map (fun node -> attribute, Index.Tree.hash_of node) let store tx description tuples = let open Utilities.Result in |
