···6565 let header =
6666 Dag_cbor.encode
6767 (`Map
6868- (Dag_cbor.StringMap.of_list
6868+ (Dag_cbor.String_map.of_list
6969 [("version", `Integer 1L); ("roots", `Array [|`Link root|])] ) )
7070 in
7171 let seq = Lwt_seq.of_list [Varint.encode (Bytes.length header); header] in
···183183 match header with
184184 | `Map m -> (
185185 let roots_v =
186186- try Some (Dag_cbor.StringMap.find "roots" m) with Not_found -> None
186186+ try Some (Dag_cbor.String_map.find "roots" m) with Not_found -> None
187187 in
188188 match roots_v with
189189 | Some (`Array arr) ->
+10-9
ipld/lib/dag_cbor.ml
···11-module StringMap = Map.Make (String)
11+module String_map = Map.Make (String)
2233-let ordered_map_keys (m : 'a StringMap.t) : string list =
44- let keys = StringMap.bindings m |> List.map fst in
33+let ordered_map_keys (m : 'a String_map.t) : string list =
44+ let keys = String_map.bindings m |> List.map fst in
55 List.sort
66 (fun a b ->
77 let la = String.length a in
···2424 | `Bytes of bytes
2525 | `String of string
2626 | `Array of value Array.t
2727- | `Map of value StringMap.t
2727+ | `Map of value String_map.t
2828 | `Link of Cid.t ]
29293030let rec of_yojson (json : Yojson.Safe.t) : value =
···3535 `Link (Result.get_ok (Cid.of_string s))
3636 | `Assoc assoc_list ->
3737 `Map
3838- (StringMap.of_list
3838+ (String_map.of_list
3939 (List.map (fun (k, v) -> (k, of_yojson v)) assoc_list) )
4040 | `List lst ->
4141 `Array (Array.of_list (List.map of_yojson lst))
···5555let rec to_yojson (value : value) : Yojson.Safe.t =
5656 match value with
5757 | `Map map ->
5858- `Assoc (StringMap.to_list map |> List.map (fun (k, v) -> (k, to_yojson v)))
5858+ `Assoc
5959+ (String_map.to_list map |> List.map (fun (k, v) -> (k, to_yojson v)))
5960 | `Array arr ->
6061 `List (Array.to_list arr |> List.map to_yojson)
6162 | `Bytes bytes ->
···192193 write_type_and_argument t 4 (Int64.of_int len) ;
193194 Array.iter (write_value t) lst
194195 | `Map m ->
195195- let len = StringMap.cardinal m in
196196+ let len = String_map.cardinal m in
196197 write_type_and_argument t 5 (Int64.of_int len) ;
197198 ordered_map_keys m
198199 |> List.iter (fun k ->
199200 write_string t k ;
200200- write_value t (StringMap.find k m) )
201201+ write_value t (String_map.find k m) )
201202 | `Link cid ->
202203 write_cid t cid
203204···353354 let len = read_argument t info in
354355 if len < 0L then invalid_arg "decode_first: negative map length" ;
355356 let rec decode_map acc n =
356356- if n <= 0 then StringMap.of_seq (List.to_seq acc)
357357+ if n <= 0 then String_map.of_seq (List.to_seq acc)
357358 else
358359 let key = decode_string_key t in
359360 let value = decode_first' () in
···11-module StringMap = Dag_cbor.StringMap
11+module String_map = Dag_cbor.String_map
2233type typed_json_ref =
44 { type': string [@key "$type"]
···6666 ; mime_type
6767 ; size= 0L }
68686969-let to_ipld blob : Dag_cbor.value StringMap.t =
7070- StringMap.of_list
6969+let to_ipld blob : Dag_cbor.value String_map.t =
7070+ String_map.of_list
7171 [ ("$type", `String "blob")
7272 ; ("ref", `Link blob.ref)
7373 ; ("mimeType", `String blob.mime_type)
···7777 match ipld with
7878 | `Map m -> (
7979 try
8080- if StringMap.mem "$type" m then
8080+ if String_map.mem "$type" m then
8181 let type' =
8282- match StringMap.find "$type" m with
8282+ match String_map.find "$type" m with
8383 | `String "blob" ->
8484 "blob"
8585 | _ ->
8686 invalid_arg "of_ipld: invalid blob ref $type"
8787 in
8888 let ref =
8989- match StringMap.find "ref" m with
8989+ match String_map.find "ref" m with
9090 | `Link ref ->
9191 ref
9292 | _ ->
9393 invalid_arg "of_ipld: invalid blob ref ref"
9494 in
9595 let mime_type =
9696- match StringMap.find "mimeType" m with
9696+ match String_map.find "mimeType" m with
9797 | `String mime_type ->
9898 mime_type
9999 | _ ->
100100 invalid_arg "of_ipld: invalid blob ref mimeType"
101101 in
102102 let size =
103103- match StringMap.find "size" m with
103103+ match String_map.find "size" m with
104104 | `Integer size ->
105105 size
106106 | _ ->
107107 invalid_arg "of_ipld: invalid blob ref size"
108108 in
109109 of_json_ref (Typed {type'; ref; mime_type; size})
110110- else if StringMap.mem "cid" m then
110110+ else if String_map.mem "cid" m then
111111 let cid =
112112- match StringMap.find "cid" m with
112112+ match String_map.find "cid" m with
113113 | `String cid ->
114114 cid
115115 | _ ->
116116 invalid_arg "of_ipld: invalid blob ref cid"
117117 in
118118 let mime_type =
119119- match StringMap.find "mimeType" m with
119119+ match String_map.find "mimeType" m with
120120 | `String mime_type ->
121121 mime_type
122122 | _ ->
+9-9
mist/lib/lex.ml
···11-module StringMap = Dag_cbor.StringMap
11+module String_map = Dag_cbor.String_map
2233type value =
44 [ Dag_cbor.value
55 | `BlobRef of Blob_ref.t
66 | `LexArray of value Array.t
77- | `LexMap of value StringMap.t ]
77+ | `LexMap of value String_map.t ]
8899let rec to_ipld (v : value) : Dag_cbor.value =
1010 match v with
···1212 match r.original with
1313 | Typed {ref; mime_type; size; _} ->
1414 `Map
1515- (StringMap.of_list
1515+ (String_map.of_list
1616 [ ("$type", `String "blob")
1717 ; ("ref", `Link ref)
1818 ; ("mimeType", `String mime_type)
1919 ; ("size", `Integer size) ] )
2020 | Untyped {cid; mime_type} ->
2121 `Map
2222- (StringMap.of_list
2222+ (String_map.of_list
2323 [("cid", `String cid); ("mimeType", `String mime_type)] ) )
2424 | `LexArray a ->
2525 `Array (Array.map to_ipld a)
2626 | `LexMap m ->
2727- `Map (StringMap.map to_ipld m)
2727+ `Map (String_map.map to_ipld m)
2828 | `Boolean b ->
2929 `Boolean b
3030 | `Integer i ->
···4848 match v with
4949 | `Map m ->
5050 if
5151- (StringMap.mem "$type" m && StringMap.find "$type" m = `String "blob")
5252- || (StringMap.mem "cid" m && StringMap.mem "mimeType" m)
5151+ (String_map.mem "$type" m && String_map.find "$type" m = `String "blob")
5252+ || (String_map.mem "cid" m && String_map.mem "mimeType" m)
5353 then `BlobRef (Blob_ref.of_ipld (`Map m))
5454- else `LexMap (StringMap.map of_ipld m)
5454+ else `LexMap (String_map.map of_ipld m)
5555 | `Array a ->
5656 `LexArray (Array.map of_ipld a)
5757 | `Boolean b ->
···8080let to_yojson (v : value) : Yojson.Safe.t = Dag_cbor.to_yojson (to_ipld v)
81818282type repo_record =
8383- (value StringMap.t
8383+ (value String_map.t
8484 [@of_yojson
8585 fun v ->
8686 match of_yojson v with
+1-1
mist/lib/mst.ml
···11open Storage
22-module String_map = Dag_cbor.StringMap
22+module String_map = Dag_cbor.String_map
3344type node_raw =
55 { (* link to lower level left subtree with all keys sorting before this node *)
+1-1
mist/test/test_mst.ml
···33open Lwt_result.Syntax
44module Mem_mst = Mst.Make (Storage.Memory_blockstore)
55module Mem_diff = Mst.Differ (Mem_mst) (Mem_mst)
66-module String_map = Dag_cbor.StringMap
66+module String_map = Dag_cbor.String_map
7788let cid_of_string_exn s =
99 match Cid.of_string s with Ok c -> c | Error msg -> failwith msg
+1-1
pegasus/lib/api/sync/getBlocks.ml
···1515 match%lwt User_store.get_blocks db cids with
1616 | {blocks; missing= []} ->
1717 let blocks_stream =
1818- Repository.BlockMap.entries blocks |> Lwt_seq.of_list
1818+ Repository.Block_map.entries blocks |> Lwt_seq.of_list
1919 in
2020 let car_stream =
2121 Lwt_seq.cons (commit_cid, commit_block) blocks_stream
+1-1
pegasus/lib/api/sync/getRecord.ml
···2121 Mst.proof_for_key {blockstore= db; root= mst_root} mst_root path
2222 in
2323 let blocks_stream =
2424- Repository.BlockMap.entries blocks |> Lwt_seq.of_list
2424+ Repository.Block_map.entries blocks |> Lwt_seq.of_list
2525 in
2626 let car_stream =
2727 Lwt_seq.cons (commit_cid, commit_block) blocks_stream
+6-2
pegasus/lib/id_resolver.ml
···131131 | `String e ->
132132 e
133133 | `List l -> (
134134- match List.hd l with `String e -> e | `StringMap m -> List.hd m |> snd )
135135- | `StringMap m ->
134134+ match List.hd l with
135135+ | `String e ->
136136+ e
137137+ | `String_map m ->
138138+ List.hd m |> snd )
139139+ | `String_map m ->
136140 List.hd m |> snd
137141138142 let get_service t fragment =
+23-24
pegasus/lib/repository.ml
···11open User_store.Types
22-module BlockMap = User_store.Block_map
22+module Block_map = User_store.Block_map
33module Lex = Mist.Lex
44module Mst = Mist.Mst.Make (User_store)
55-module MemMst = Mist.Mst.Make (Mist.Storage.Memory_blockstore)
66-module StringMap = Lex.StringMap
55+module String_map = Lex.String_map
76module Tid = Mist.Tid
8798module Write_op = struct
···140139 { key: Kleidos.key
141140 ; did: string
142141 ; db: User_store.t
143143- ; mutable block_map: Cid.t StringMap.t option
142142+ ; mutable block_map: Cid.t String_map.t option
144143 ; mutable commit: (Cid.t * signed_commit) option }
145144146146-let get_map t : Cid.t StringMap.t Lwt.t =
145145+let get_map t : Cid.t String_map.t Lwt.t =
147146 let%lwt root, commit =
148147 match%lwt User_store.get_commit t.db with
149148 | Some (r, c) ->
···162161163162let get_record_cid t path : Cid.t option Lwt.t =
164163 let%lwt map = get_map t in
165165- Lwt.return @@ StringMap.find_opt path map
164164+ Lwt.return @@ String_map.find_opt path map
166165167166let get_record t path : record option Lwt.t =
168167 User_store.get_record_by_path t.db path
···170169let list_collections t : string list Lwt.t =
171170 let module Set = Set.Make (String) in
172171 let%lwt map = get_map t in
173173- StringMap.bindings map
172172+ String_map.bindings map
174173 |> List.fold_left
175174 (fun (acc : Set.t) (path, _) ->
176175 let collection = String.split_on_char '/' path |> List.hd in
···180179181180let list_all_records t collection : (string * Cid.t * record) list Lwt.t =
182181 let%lwt map = get_map t in
183183- StringMap.bindings map
182182+ String_map.bindings map
184183 |> List.filter (fun (path, _) ->
185184 String.starts_with ~prefix:(path ^ "/") collection )
186185 |> Lwt_list.fold_left_s
···255254 let%lwt block_map = Lwt.map ref (get_map t) in
256255 (* ops to emit, built in loop because prev_data (previous cid) is otherwise inaccessible *)
257256 let commit_ops : commit_evt_op list ref = ref [] in
258258- let added_leaves = ref BlockMap.empty in
257257+ let added_leaves = ref Block_map.empty in
259258 let%lwt results =
260259 List.map
261260 (fun (w : repo_write) ->
···265264 let path = Format.sprintf "%s/%s" collection rkey in
266265 let uri = Format.sprintf "at://%s/%s" t.did path in
267266 let%lwt () =
268268- match StringMap.find_opt path !block_map with
267267+ match String_map.find_opt path !block_map with
269268 | Some cid ->
270269 Errors.invalid_request ~name:"InvalidSwap"
271270 (Format.sprintf
···276275 Lwt.return ()
277276 in
278277 let record_with_type : Lex.repo_record =
279279- if StringMap.mem "$type" value then value
280280- else StringMap.add "$type" (`String collection) value
278278+ if String_map.mem "$type" value then value
279279+ else String_map.add "$type" (`String collection) value
281280 in
282281 let%lwt cid, block =
283282 User_store.put_record t.db (`LexMap record_with_type) path
284283 in
285285- block_map := StringMap.add path cid !block_map ;
286286- added_leaves := BlockMap.set cid block !added_leaves ;
284284+ block_map := String_map.add path cid !block_map ;
285285+ added_leaves := Block_map.set cid block !added_leaves ;
287286 commit_ops :=
288287 !commit_ops @ [{action= `Create; path; cid= Some cid; prev= None}] ;
289288 let refs =
···304303 | Update {collection; rkey; value; swap_record; _} ->
305304 let path = Format.sprintf "%s/%s" collection rkey in
306305 let uri = Format.sprintf "at://%s/%s" t.did path in
307307- let old_cid = StringMap.find_opt path !block_map in
306306+ let old_cid = String_map.find_opt path !block_map in
308307 ( if
309308 (swap_record <> None && swap_record <> old_cid)
310309 || (swap_record = None && old_cid = None)
···336335 Lwt.return_unit
337336 in
338337 let record_with_type : Lex.repo_record =
339339- if StringMap.mem "$type" value then value
340340- else StringMap.add "$type" (`String collection) value
338338+ if String_map.mem "$type" value then value
339339+ else String_map.add "$type" (`String collection) value
341340 in
342341 let%lwt new_cid, new_block =
343342 User_store.put_record t.db (`LexMap record_with_type) path
344343 in
345345- added_leaves := BlockMap.set new_cid new_block !added_leaves ;
346346- block_map := StringMap.add path new_cid !block_map ;
344344+ added_leaves := Block_map.set new_cid new_block !added_leaves ;
345345+ block_map := String_map.add path new_cid !block_map ;
347346 commit_ops :=
348347 !commit_ops
349348 @ [{action= `Update; path; cid= Some new_cid; prev= old_cid}] ;
···354353 ; cid= new_cid } )
355354 | Delete {collection; rkey; swap_record; _} ->
356355 let path = Format.sprintf "%s/%s" collection rkey in
357357- let cid = StringMap.find_opt path !block_map in
356356+ let cid = String_map.find_opt path !block_map in
358357 ( if cid = None || (swap_record <> None && swap_record <> cid) then
359358 let cid_str =
360359 match cid with
···378377 | None ->
379378 Lwt.return_unit
380379 in
381381- block_map := StringMap.remove path !block_map ;
380380+ block_map := String_map.remove path !block_map ;
382381 commit_ops :=
383382 !commit_ops @ [{action= `Delete; path; cid= None; prev= cid}] ;
384383 Lwt.return
···387386 |> Lwt.all
388387 in
389388 let%lwt () = User_store.clear_mst t.db in
390390- let%lwt new_mst = Mst.of_assoc t.db (StringMap.bindings !block_map) in
389389+ let%lwt new_mst = Mst.of_assoc t.db (String_map.bindings !block_map) in
391390 let%lwt new_commit = put_commit t new_mst.root ~previous:(Some prev_commit) in
392391 let new_commit_cid, new_commit_signed = new_commit in
393392 let commit_block =
···412411 ~prev_root:prev_commit.data
413412 with
414413 | Ok blocks ->
415415- Lwt.return (BlockMap.merge blocks !added_leaves)
414414+ Lwt.return (Block_map.merge blocks !added_leaves)
416415 | Error err ->
417416 raise err
418417 in
419418 let block_stream =
420420- proof_blocks |> BlockMap.entries |> Lwt_seq.of_list
419419+ proof_blocks |> Block_map.entries |> Lwt_seq.of_list
421420 |> Lwt_seq.cons (new_commit_cid, commit_block)
422421 in
423422 let%lwt blocks =
+9-9
pegasus/lib/util.ml
···119119 | _ ->
120120 Error "invalid field value"
121121122122- type string_or_string_map = [`String of string | `StringMap of string_map]
122122+ type string_or_string_map = [`String of string | `String_map of string_map]
123123124124 let string_or_string_map_to_yojson = function
125125 | `String c ->
126126 `String c
127127- | `StringMap m ->
127127+ | `String_map m ->
128128 `Assoc (List.map (fun (k, v) -> (k, `String v)) m)
129129130130 let string_or_string_map_of_yojson = function
131131 | `String c ->
132132- Ok (`StringMap [(c, "")])
132132+ Ok (`String_map [(c, "")])
133133 | `Assoc m ->
134134 Ok
135135- (`StringMap
135135+ (`String_map
136136 (List.map (fun (k, v) -> (k, Yojson.Safe.Util.to_string v)) m) )
137137 | _ ->
138138 Error "invalid field value"
139139140140 type string_or_string_map_or_either_list =
141141 [ `String of string
142142- | `StringMap of string_map
142142+ | `String_map of string_map
143143 | `List of string_or_string_map list ]
144144145145 let string_or_string_map_or_either_list_to_yojson = function
146146 | `String c ->
147147 `String c
148148- | `StringMap m ->
148148+ | `String_map m ->
149149 `Assoc (List.map (fun (k, v) -> (k, `String v)) m)
150150 | `List l ->
151151 `List (List.map string_or_string_map_to_yojson l)
152152153153 let string_or_string_map_or_either_list_of_yojson = function
154154 | `String c ->
155155- Ok (`StringMap [(c, "")])
155155+ Ok (`String_map [(c, "")])
156156 | `Assoc m ->
157157 Ok
158158- (`StringMap
158158+ (`String_map
159159 (List.map (fun (k, v) -> (k, Yojson.Safe.Util.to_string v)) m) )
160160 | `List l ->
161161 Ok
···281281 (fun acc (_, value) ->
282282 match value with `BlobRef blob -> blob :: acc | _ -> acc )
283283 []
284284- (Mist.Lex.StringMap.bindings record)
284284+ (Mist.Lex.String_map.bindings record)
285285286286(* returns whether the value is None *)
287287let is_none = function None -> true | _ -> false