objective categorical abstract machine language personal data server
65
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make casing consistent

futurGH 835f704b a637840a

+148 -144
+2 -2
ipld/lib/car.ml
··· 65 65 let header = 66 66 Dag_cbor.encode 67 67 (`Map 68 - (Dag_cbor.StringMap.of_list 68 + (Dag_cbor.String_map.of_list 69 69 [("version", `Integer 1L); ("roots", `Array [|`Link root|])] ) ) 70 70 in 71 71 let seq = Lwt_seq.of_list [Varint.encode (Bytes.length header); header] in ··· 183 183 match header with 184 184 | `Map m -> ( 185 185 let roots_v = 186 - try Some (Dag_cbor.StringMap.find "roots" m) with Not_found -> None 186 + try Some (Dag_cbor.String_map.find "roots" m) with Not_found -> None 187 187 in 188 188 match roots_v with 189 189 | Some (`Array arr) ->
+10 -9
ipld/lib/dag_cbor.ml
··· 1 - module StringMap = Map.Make (String) 1 + module String_map = Map.Make (String) 2 2 3 - let ordered_map_keys (m : 'a StringMap.t) : string list = 4 - let keys = StringMap.bindings m |> List.map fst in 3 + let ordered_map_keys (m : 'a String_map.t) : string list = 4 + let keys = String_map.bindings m |> List.map fst in 5 5 List.sort 6 6 (fun a b -> 7 7 let la = String.length a in ··· 24 24 | `Bytes of bytes 25 25 | `String of string 26 26 | `Array of value Array.t 27 - | `Map of value StringMap.t 27 + | `Map of value String_map.t 28 28 | `Link of Cid.t ] 29 29 30 30 let rec of_yojson (json : Yojson.Safe.t) : value = ··· 35 35 `Link (Result.get_ok (Cid.of_string s)) 36 36 | `Assoc assoc_list -> 37 37 `Map 38 - (StringMap.of_list 38 + (String_map.of_list 39 39 (List.map (fun (k, v) -> (k, of_yojson v)) assoc_list) ) 40 40 | `List lst -> 41 41 `Array (Array.of_list (List.map of_yojson lst)) ··· 55 55 let rec to_yojson (value : value) : Yojson.Safe.t = 56 56 match value with 57 57 | `Map map -> 58 - `Assoc (StringMap.to_list map |> List.map (fun (k, v) -> (k, to_yojson v))) 58 + `Assoc 59 + (String_map.to_list map |> List.map (fun (k, v) -> (k, to_yojson v))) 59 60 | `Array arr -> 60 61 `List (Array.to_list arr |> List.map to_yojson) 61 62 | `Bytes bytes -> ··· 192 193 write_type_and_argument t 4 (Int64.of_int len) ; 193 194 Array.iter (write_value t) lst 194 195 | `Map m -> 195 - let len = StringMap.cardinal m in 196 + let len = String_map.cardinal m in 196 197 write_type_and_argument t 5 (Int64.of_int len) ; 197 198 ordered_map_keys m 198 199 |> List.iter (fun k -> 199 200 write_string t k ; 200 - write_value t (StringMap.find k m) ) 201 + write_value t (String_map.find k m) ) 201 202 | `Link cid -> 202 203 write_cid t cid 203 204 ··· 353 354 let len = read_argument t info in 354 355 if len < 0L then invalid_arg "decode_first: negative map length" ; 355 356 let rec decode_map acc n = 356 - if n <= 0 then StringMap.of_seq (List.to_seq acc) 357 + if n <= 0 then String_map.of_seq (List.to_seq acc) 357 358 else 358 359 let key = decode_string_key t in 359 360 let value = decode_first' () in
+74 -74
ipld/test/test_dag_cbor.ml
··· 1 - module StringMap = Dag_cbor.StringMap 1 + module String_map = Dag_cbor.String_map 2 2 3 3 let rec stringify_map m = 4 - StringMap.bindings m 4 + String_map.bindings m 5 5 |> List.map (fun (k, v) -> 6 6 Format.sprintf "\"%s\": %s" k (stringify_ipld_value v) ) 7 7 |> String.concat ", " |> Format.sprintf "{%s}" ··· 29 29 | `Link cid -> 30 30 Format.sprintf "%s" 31 31 (stringify_map 32 - (StringMap.singleton "$link" (`String (Cid.to_string cid))) ) 32 + (String_map.singleton "$link" (`String (Cid.to_string cid))) ) 33 33 | `Null -> 34 34 Format.sprintf "null" 35 35 ··· 48 48 | `Bytes a, `Bytes b -> 49 49 a = b 50 50 | `Map a, `Map b -> 51 - StringMap.equal ipld_value_eq a b 51 + String_map.equal ipld_value_eq a b 52 52 | `Array a, `Array b -> 53 53 Array.for_all2 ipld_value_eq a b 54 54 | `Link a, `Link b -> ··· 166 166 by taking our honey, you're not only taking away everything we have, \ 167 167 but everything we are!" |] 168 168 in 169 - let nested_map = StringMap.add "hello" (`String "world") StringMap.empty in 169 + let nested_map = String_map.add "hello" (`String "world") String_map.empty in 170 170 let object_map = 171 - StringMap.empty 172 - |> StringMap.add "key" (`String "value") 173 - |> StringMap.add "link" (`Link test_cid) 174 - |> StringMap.add "bytes" (`Bytes test_bytes) 175 - |> StringMap.add "answer" (`Integer 42L) 176 - |> StringMap.add "correct" (`Boolean true) 177 - |> StringMap.add "wrong" (`Boolean false) 178 - |> StringMap.add "blank" `Null 179 - |> StringMap.add "b16" (`Integer 262L) 180 - |> StringMap.add "b32" (`Integer 65542L) 181 - |> StringMap.add "minInteger" (`Integer (-9007199254740991L)) 182 - |> StringMap.add "maxInteger" (`Integer 9007199254740991L) 183 - |> StringMap.add "pi" (`Float 3.141592653589793) 184 - |> StringMap.add "npi" (`Float (-3.141592653589793)) 185 - |> StringMap.add "nested" (`Map nested_map) 186 - |> StringMap.add "bee" (`Array bee_array) 171 + String_map.empty 172 + |> String_map.add "key" (`String "value") 173 + |> String_map.add "link" (`Link test_cid) 174 + |> String_map.add "bytes" (`Bytes test_bytes) 175 + |> String_map.add "answer" (`Integer 42L) 176 + |> String_map.add "correct" (`Boolean true) 177 + |> String_map.add "wrong" (`Boolean false) 178 + |> String_map.add "blank" `Null 179 + |> String_map.add "b16" (`Integer 262L) 180 + |> String_map.add "b32" (`Integer 65542L) 181 + |> String_map.add "minInteger" (`Integer (-9007199254740991L)) 182 + |> String_map.add "maxInteger" (`Integer 9007199254740991L) 183 + |> String_map.add "pi" (`Float 3.141592653589793) 184 + |> String_map.add "npi" (`Float (-3.141592653589793)) 185 + |> String_map.add "nested" (`Map nested_map) 186 + |> String_map.add "bee" (`Array bee_array) 187 187 in 188 188 let original = `Map object_map in 189 189 let encoded = Dag_cbor.encode original in ··· 192 192 "round trip preserves structure" original decoded 193 193 194 194 let test_atproto_post_records () = 195 - let record1_embed_images_0_aspect_ratio : Dag_cbor.value StringMap.t = 196 - StringMap.( 195 + let record1_embed_images_0_aspect_ratio : Dag_cbor.value String_map.t = 196 + String_map.( 197 197 empty |> add "height" (`Integer 885L) |> add "width" (`Integer 665L) ) 198 198 in 199 - let record1_embed_images_0_image : Dag_cbor.value StringMap.t = 200 - StringMap.( 199 + let record1_embed_images_0_image : Dag_cbor.value String_map.t = 200 + String_map.( 201 201 empty 202 202 |> add "$type" (`String "blob") 203 203 |> add "ref" ··· 209 209 |> add "mimeType" (`String "image/jpeg") 210 210 |> add "size" (`Integer 645553L) ) 211 211 in 212 - let record1_embed_images_0 : Dag_cbor.value StringMap.t = 213 - StringMap.( 212 + let record1_embed_images_0 : Dag_cbor.value String_map.t = 213 + String_map.( 214 214 empty 215 215 |> add "alt" 216 216 (`String ··· 219 219 |> add "aspectRatio" (`Map record1_embed_images_0_aspect_ratio) 220 220 |> add "image" (`Map record1_embed_images_0_image) ) 221 221 in 222 - let record1_embed : Dag_cbor.value StringMap.t = 223 - StringMap.( 222 + let record1_embed : Dag_cbor.value String_map.t = 223 + String_map.( 224 224 empty 225 225 |> add "$type" (`String "app.bsky.embed.images") 226 226 |> add "images" (`Array [|`Map record1_embed_images_0|]) ) 227 227 in 228 228 let record1 : Dag_cbor.value = 229 229 `Map 230 - StringMap.( 230 + String_map.( 231 231 empty 232 232 |> add "$type" (`String "app.bsky.feed.post") 233 233 |> add "createdAt" (`String "2024-08-13T01:16:06.453Z") ··· 240 240 "atproto record 1 encodes correctly" 241 241 "bafyreicbb3p4hmtm7iw3k7kiydzqp7qhufq3jdc5sbc4gxa4mxqd6bywba" 242 242 Cid.(create Dcbor encoded1 |> to_string) ; 243 - let record2_embed_images_0_aspect_ratio : Dag_cbor.value StringMap.t = 244 - StringMap.( 243 + let record2_embed_images_0_aspect_ratio : Dag_cbor.value String_map.t = 244 + String_map.( 245 245 empty |> add "height" (`Integer 2000L) |> add "width" (`Integer 1500L) ) 246 246 in 247 - let record2_embed_images_0_image : Dag_cbor.value StringMap.t = 248 - StringMap.( 247 + let record2_embed_images_0_image : Dag_cbor.value String_map.t = 248 + String_map.( 249 249 empty 250 250 |> add "$type" (`String "blob") 251 251 |> add "ref" ··· 257 257 |> add "mimeType" (`String "image/jpeg") 258 258 |> add "size" (`Integer 531257L) ) 259 259 in 260 - let record2_embed_images_0 : Dag_cbor.value StringMap.t = 261 - StringMap.( 260 + let record2_embed_images_0 : Dag_cbor.value String_map.t = 261 + String_map.( 262 262 empty 263 263 |> add "alt" (`String "") 264 264 |> add "aspectRatio" (`Map record2_embed_images_0_aspect_ratio) 265 265 |> add "image" (`Map record2_embed_images_0_image) ) 266 266 in 267 - let record2_embed : Dag_cbor.value StringMap.t = 268 - StringMap.( 267 + let record2_embed : Dag_cbor.value String_map.t = 268 + String_map.( 269 269 empty 270 270 |> add "$type" (`String "app.bsky.embed.images") 271 271 |> add "images" (`Array [|`Map record2_embed_images_0|]) ) 272 272 in 273 - let record2_facets_0 : Dag_cbor.value StringMap.t = 274 - StringMap.( 273 + let record2_facets_0 : Dag_cbor.value String_map.t = 274 + String_map.( 275 275 empty 276 276 |> add "features" 277 277 (`Array 278 278 [| `Map 279 - ( StringMap.empty 280 - |> StringMap.add "$type" 279 + ( String_map.empty 280 + |> String_map.add "$type" 281 281 (`String "app.bsky.richtext.facet#tag") 282 - |> StringMap.add "tag" (`String "写真") ) |] ) 282 + |> String_map.add "tag" (`String "写真") ) |] ) 283 283 |> add "index" 284 284 (`Map 285 - ( StringMap.empty 286 - |> StringMap.add "byteEnd" (`Integer 109L) 287 - |> StringMap.add "byteStart" (`Integer 100L) ) ) ) 285 + ( String_map.empty 286 + |> String_map.add "byteEnd" (`Integer 109L) 287 + |> String_map.add "byteStart" (`Integer 100L) ) ) ) 288 288 in 289 - let record2_facets_1 : Dag_cbor.value StringMap.t = 290 - StringMap.( 289 + let record2_facets_1 : Dag_cbor.value String_map.t = 290 + String_map.( 291 291 empty 292 292 |> add "features" 293 293 (`Array 294 294 [| `Map 295 - ( StringMap.empty 296 - |> StringMap.add "$type" 295 + ( String_map.empty 296 + |> String_map.add "$type" 297 297 (`String "app.bsky.richtext.facet#tag") 298 - |> StringMap.add "tag" (`String "日の出") ) |] ) 298 + |> String_map.add "tag" (`String "日の出") ) |] ) 299 299 |> add "index" 300 300 (`Map 301 - ( StringMap.empty 302 - |> StringMap.add "byteEnd" (`Integer 122L) 303 - |> StringMap.add "byteStart" (`Integer 110L) ) ) ) 301 + ( String_map.empty 302 + |> String_map.add "byteEnd" (`Integer 122L) 303 + |> String_map.add "byteStart" (`Integer 110L) ) ) ) 304 304 in 305 - let record2_facets_2 : Dag_cbor.value StringMap.t = 306 - StringMap.( 305 + let record2_facets_2 : Dag_cbor.value String_map.t = 306 + String_map.( 307 307 empty 308 308 |> add "features" 309 309 (`Array 310 310 [| `Map 311 - ( StringMap.empty 312 - |> StringMap.add "$type" 311 + ( String_map.empty 312 + |> String_map.add "$type" 313 313 (`String "app.bsky.richtext.facet#tag") 314 - |> StringMap.add "tag" (`String "日常") ) |] ) 314 + |> String_map.add "tag" (`String "日常") ) |] ) 315 315 |> add "index" 316 316 (`Map 317 - ( StringMap.empty 318 - |> StringMap.add "byteEnd" (`Integer 132L) 319 - |> StringMap.add "byteStart" (`Integer 123L) ) ) ) 317 + ( String_map.empty 318 + |> String_map.add "byteEnd" (`Integer 132L) 319 + |> String_map.add "byteStart" (`Integer 123L) ) ) ) 320 320 in 321 - let record2_facets_3 : Dag_cbor.value StringMap.t = 322 - StringMap.( 321 + let record2_facets_3 : Dag_cbor.value String_map.t = 322 + String_map.( 323 323 empty 324 324 |> add "features" 325 325 (`Array 326 326 [| `Map 327 - ( StringMap.empty 328 - |> StringMap.add "$type" 327 + ( String_map.empty 328 + |> String_map.add "$type" 329 329 (`String "app.bsky.richtext.facet#tag") 330 - |> StringMap.add "tag" (`String "キリトリセカイ") ) |] ) 330 + |> String_map.add "tag" (`String "キリトリセカイ") ) |] ) 331 331 |> add "index" 332 332 (`Map 333 - ( StringMap.empty 334 - |> StringMap.add "byteEnd" (`Integer 157L) 335 - |> StringMap.add "byteStart" (`Integer 133L) ) ) ) 333 + ( String_map.empty 334 + |> String_map.add "byteEnd" (`Integer 157L) 335 + |> String_map.add "byteStart" (`Integer 133L) ) ) ) 336 336 in 337 337 let record2_facets = 338 338 [| `Map record2_facets_0 ··· 340 340 ; `Map record2_facets_2 341 341 ; `Map record2_facets_3 |] 342 342 in 343 - let record2_map : Dag_cbor.value StringMap.t = 344 - StringMap.( 343 + let record2_map : Dag_cbor.value String_map.t = 344 + String_map.( 345 345 empty 346 346 |> add "$type" (`String "app.bsky.feed.post") 347 347 |> add "createdAt" (`String "2025-01-02T23:29:41.149Z") ··· 373 373 ignore (Dag_cbor.encode (`Integer (-9007199254740992L))) ) 374 374 375 375 let test_decode_multiple_objects () = 376 - let obj1 = `Map (StringMap.add "foo" (`Boolean true) StringMap.empty) in 377 - let obj2 = `Map (StringMap.add "bar" (`Boolean false) StringMap.empty) in 376 + let obj1 = `Map (String_map.add "foo" (`Boolean true) String_map.empty) in 377 + let obj2 = `Map (String_map.add "bar" (`Boolean false) String_map.empty) in 378 378 let encoded1 = Dag_cbor.encode obj1 in 379 379 let encoded2 = Dag_cbor.encode obj2 in 380 380 let combined = Bytes.create (Bytes.length encoded1 + Bytes.length encoded2) in
+11 -11
mist/lib/blob_ref.ml
··· 1 - module StringMap = Dag_cbor.StringMap 1 + module String_map = Dag_cbor.String_map 2 2 3 3 type typed_json_ref = 4 4 { type': string [@key "$type"] ··· 66 66 ; mime_type 67 67 ; size= 0L } 68 68 69 - let to_ipld blob : Dag_cbor.value StringMap.t = 70 - StringMap.of_list 69 + let to_ipld blob : Dag_cbor.value String_map.t = 70 + String_map.of_list 71 71 [ ("$type", `String "blob") 72 72 ; ("ref", `Link blob.ref) 73 73 ; ("mimeType", `String blob.mime_type) ··· 77 77 match ipld with 78 78 | `Map m -> ( 79 79 try 80 - if StringMap.mem "$type" m then 80 + if String_map.mem "$type" m then 81 81 let type' = 82 - match StringMap.find "$type" m with 82 + match String_map.find "$type" m with 83 83 | `String "blob" -> 84 84 "blob" 85 85 | _ -> 86 86 invalid_arg "of_ipld: invalid blob ref $type" 87 87 in 88 88 let ref = 89 - match StringMap.find "ref" m with 89 + match String_map.find "ref" m with 90 90 | `Link ref -> 91 91 ref 92 92 | _ -> 93 93 invalid_arg "of_ipld: invalid blob ref ref" 94 94 in 95 95 let mime_type = 96 - match StringMap.find "mimeType" m with 96 + match String_map.find "mimeType" m with 97 97 | `String mime_type -> 98 98 mime_type 99 99 | _ -> 100 100 invalid_arg "of_ipld: invalid blob ref mimeType" 101 101 in 102 102 let size = 103 - match StringMap.find "size" m with 103 + match String_map.find "size" m with 104 104 | `Integer size -> 105 105 size 106 106 | _ -> 107 107 invalid_arg "of_ipld: invalid blob ref size" 108 108 in 109 109 of_json_ref (Typed {type'; ref; mime_type; size}) 110 - else if StringMap.mem "cid" m then 110 + else if String_map.mem "cid" m then 111 111 let cid = 112 - match StringMap.find "cid" m with 112 + match String_map.find "cid" m with 113 113 | `String cid -> 114 114 cid 115 115 | _ -> 116 116 invalid_arg "of_ipld: invalid blob ref cid" 117 117 in 118 118 let mime_type = 119 - match StringMap.find "mimeType" m with 119 + match String_map.find "mimeType" m with 120 120 | `String mime_type -> 121 121 mime_type 122 122 | _ ->
+9 -9
mist/lib/lex.ml
··· 1 - module StringMap = Dag_cbor.StringMap 1 + module String_map = Dag_cbor.String_map 2 2 3 3 type value = 4 4 [ Dag_cbor.value 5 5 | `BlobRef of Blob_ref.t 6 6 | `LexArray of value Array.t 7 - | `LexMap of value StringMap.t ] 7 + | `LexMap of value String_map.t ] 8 8 9 9 let rec to_ipld (v : value) : Dag_cbor.value = 10 10 match v with ··· 12 12 match r.original with 13 13 | Typed {ref; mime_type; size; _} -> 14 14 `Map 15 - (StringMap.of_list 15 + (String_map.of_list 16 16 [ ("$type", `String "blob") 17 17 ; ("ref", `Link ref) 18 18 ; ("mimeType", `String mime_type) 19 19 ; ("size", `Integer size) ] ) 20 20 | Untyped {cid; mime_type} -> 21 21 `Map 22 - (StringMap.of_list 22 + (String_map.of_list 23 23 [("cid", `String cid); ("mimeType", `String mime_type)] ) ) 24 24 | `LexArray a -> 25 25 `Array (Array.map to_ipld a) 26 26 | `LexMap m -> 27 - `Map (StringMap.map to_ipld m) 27 + `Map (String_map.map to_ipld m) 28 28 | `Boolean b -> 29 29 `Boolean b 30 30 | `Integer i -> ··· 48 48 match v with 49 49 | `Map m -> 50 50 if 51 - (StringMap.mem "$type" m && StringMap.find "$type" m = `String "blob") 52 - || (StringMap.mem "cid" m && StringMap.mem "mimeType" m) 51 + (String_map.mem "$type" m && String_map.find "$type" m = `String "blob") 52 + || (String_map.mem "cid" m && String_map.mem "mimeType" m) 53 53 then `BlobRef (Blob_ref.of_ipld (`Map m)) 54 - else `LexMap (StringMap.map of_ipld m) 54 + else `LexMap (String_map.map of_ipld m) 55 55 | `Array a -> 56 56 `LexArray (Array.map of_ipld a) 57 57 | `Boolean b -> ··· 80 80 let to_yojson (v : value) : Yojson.Safe.t = Dag_cbor.to_yojson (to_ipld v) 81 81 82 82 type repo_record = 83 - (value StringMap.t 83 + (value String_map.t 84 84 [@of_yojson 85 85 fun v -> 86 86 match of_yojson v with
+1 -1
mist/lib/mst.ml
··· 1 1 open Storage 2 - module String_map = Dag_cbor.StringMap 2 + module String_map = Dag_cbor.String_map 3 3 4 4 type node_raw = 5 5 { (* link to lower level left subtree with all keys sorting before this node *)
+1 -1
mist/test/test_mst.ml
··· 3 3 open Lwt_result.Syntax 4 4 module Mem_mst = Mst.Make (Storage.Memory_blockstore) 5 5 module Mem_diff = Mst.Differ (Mem_mst) (Mem_mst) 6 - module String_map = Dag_cbor.StringMap 6 + module String_map = Dag_cbor.String_map 7 7 8 8 let cid_of_string_exn s = 9 9 match Cid.of_string s with Ok c -> c | Error msg -> failwith msg
+1 -1
pegasus/lib/api/sync/getBlocks.ml
··· 15 15 match%lwt User_store.get_blocks db cids with 16 16 | {blocks; missing= []} -> 17 17 let blocks_stream = 18 - Repository.BlockMap.entries blocks |> Lwt_seq.of_list 18 + Repository.Block_map.entries blocks |> Lwt_seq.of_list 19 19 in 20 20 let car_stream = 21 21 Lwt_seq.cons (commit_cid, commit_block) blocks_stream
+1 -1
pegasus/lib/api/sync/getRecord.ml
··· 21 21 Mst.proof_for_key {blockstore= db; root= mst_root} mst_root path 22 22 in 23 23 let blocks_stream = 24 - Repository.BlockMap.entries blocks |> Lwt_seq.of_list 24 + Repository.Block_map.entries blocks |> Lwt_seq.of_list 25 25 in 26 26 let car_stream = 27 27 Lwt_seq.cons (commit_cid, commit_block) blocks_stream
+6 -2
pegasus/lib/id_resolver.ml
··· 131 131 | `String e -> 132 132 e 133 133 | `List l -> ( 134 - match List.hd l with `String e -> e | `StringMap m -> List.hd m |> snd ) 135 - | `StringMap m -> 134 + match List.hd l with 135 + | `String e -> 136 + e 137 + | `String_map m -> 138 + List.hd m |> snd ) 139 + | `String_map m -> 136 140 List.hd m |> snd 137 141 138 142 let get_service t fragment =
+23 -24
pegasus/lib/repository.ml
··· 1 1 open User_store.Types 2 - module BlockMap = User_store.Block_map 2 + module Block_map = User_store.Block_map 3 3 module Lex = Mist.Lex 4 4 module Mst = Mist.Mst.Make (User_store) 5 - module MemMst = Mist.Mst.Make (Mist.Storage.Memory_blockstore) 6 - module StringMap = Lex.StringMap 5 + module String_map = Lex.String_map 7 6 module Tid = Mist.Tid 8 7 9 8 module Write_op = struct ··· 140 139 { key: Kleidos.key 141 140 ; did: string 142 141 ; db: User_store.t 143 - ; mutable block_map: Cid.t StringMap.t option 142 + ; mutable block_map: Cid.t String_map.t option 144 143 ; mutable commit: (Cid.t * signed_commit) option } 145 144 146 - let get_map t : Cid.t StringMap.t Lwt.t = 145 + let get_map t : Cid.t String_map.t Lwt.t = 147 146 let%lwt root, commit = 148 147 match%lwt User_store.get_commit t.db with 149 148 | Some (r, c) -> ··· 162 161 163 162 let get_record_cid t path : Cid.t option Lwt.t = 164 163 let%lwt map = get_map t in 165 - Lwt.return @@ StringMap.find_opt path map 164 + Lwt.return @@ String_map.find_opt path map 166 165 167 166 let get_record t path : record option Lwt.t = 168 167 User_store.get_record_by_path t.db path ··· 170 169 let list_collections t : string list Lwt.t = 171 170 let module Set = Set.Make (String) in 172 171 let%lwt map = get_map t in 173 - StringMap.bindings map 172 + String_map.bindings map 174 173 |> List.fold_left 175 174 (fun (acc : Set.t) (path, _) -> 176 175 let collection = String.split_on_char '/' path |> List.hd in ··· 180 179 181 180 let list_all_records t collection : (string * Cid.t * record) list Lwt.t = 182 181 let%lwt map = get_map t in 183 - StringMap.bindings map 182 + String_map.bindings map 184 183 |> List.filter (fun (path, _) -> 185 184 String.starts_with ~prefix:(path ^ "/") collection ) 186 185 |> Lwt_list.fold_left_s ··· 255 254 let%lwt block_map = Lwt.map ref (get_map t) in 256 255 (* ops to emit, built in loop because prev_data (previous cid) is otherwise inaccessible *) 257 256 let commit_ops : commit_evt_op list ref = ref [] in 258 - let added_leaves = ref BlockMap.empty in 257 + let added_leaves = ref Block_map.empty in 259 258 let%lwt results = 260 259 List.map 261 260 (fun (w : repo_write) -> ··· 265 264 let path = Format.sprintf "%s/%s" collection rkey in 266 265 let uri = Format.sprintf "at://%s/%s" t.did path in 267 266 let%lwt () = 268 - match StringMap.find_opt path !block_map with 267 + match String_map.find_opt path !block_map with 269 268 | Some cid -> 270 269 Errors.invalid_request ~name:"InvalidSwap" 271 270 (Format.sprintf ··· 276 275 Lwt.return () 277 276 in 278 277 let record_with_type : Lex.repo_record = 279 - if StringMap.mem "$type" value then value 280 - else StringMap.add "$type" (`String collection) value 278 + if String_map.mem "$type" value then value 279 + else String_map.add "$type" (`String collection) value 281 280 in 282 281 let%lwt cid, block = 283 282 User_store.put_record t.db (`LexMap record_with_type) path 284 283 in 285 - block_map := StringMap.add path cid !block_map ; 286 - added_leaves := BlockMap.set cid block !added_leaves ; 284 + block_map := String_map.add path cid !block_map ; 285 + added_leaves := Block_map.set cid block !added_leaves ; 287 286 commit_ops := 288 287 !commit_ops @ [{action= `Create; path; cid= Some cid; prev= None}] ; 289 288 let refs = ··· 304 303 | Update {collection; rkey; value; swap_record; _} -> 305 304 let path = Format.sprintf "%s/%s" collection rkey in 306 305 let uri = Format.sprintf "at://%s/%s" t.did path in 307 - let old_cid = StringMap.find_opt path !block_map in 306 + let old_cid = String_map.find_opt path !block_map in 308 307 ( if 309 308 (swap_record <> None && swap_record <> old_cid) 310 309 || (swap_record = None && old_cid = None) ··· 336 335 Lwt.return_unit 337 336 in 338 337 let record_with_type : Lex.repo_record = 339 - if StringMap.mem "$type" value then value 340 - else StringMap.add "$type" (`String collection) value 338 + if String_map.mem "$type" value then value 339 + else String_map.add "$type" (`String collection) value 341 340 in 342 341 let%lwt new_cid, new_block = 343 342 User_store.put_record t.db (`LexMap record_with_type) path 344 343 in 345 - added_leaves := BlockMap.set new_cid new_block !added_leaves ; 346 - block_map := StringMap.add path new_cid !block_map ; 344 + added_leaves := Block_map.set new_cid new_block !added_leaves ; 345 + block_map := String_map.add path new_cid !block_map ; 347 346 commit_ops := 348 347 !commit_ops 349 348 @ [{action= `Update; path; cid= Some new_cid; prev= old_cid}] ; ··· 354 353 ; cid= new_cid } ) 355 354 | Delete {collection; rkey; swap_record; _} -> 356 355 let path = Format.sprintf "%s/%s" collection rkey in 357 - let cid = StringMap.find_opt path !block_map in 356 + let cid = String_map.find_opt path !block_map in 358 357 ( if cid = None || (swap_record <> None && swap_record <> cid) then 359 358 let cid_str = 360 359 match cid with ··· 378 377 | None -> 379 378 Lwt.return_unit 380 379 in 381 - block_map := StringMap.remove path !block_map ; 380 + block_map := String_map.remove path !block_map ; 382 381 commit_ops := 383 382 !commit_ops @ [{action= `Delete; path; cid= None; prev= cid}] ; 384 383 Lwt.return ··· 387 386 |> Lwt.all 388 387 in 389 388 let%lwt () = User_store.clear_mst t.db in 390 - let%lwt new_mst = Mst.of_assoc t.db (StringMap.bindings !block_map) in 389 + let%lwt new_mst = Mst.of_assoc t.db (String_map.bindings !block_map) in 391 390 let%lwt new_commit = put_commit t new_mst.root ~previous:(Some prev_commit) in 392 391 let new_commit_cid, new_commit_signed = new_commit in 393 392 let commit_block = ··· 412 411 ~prev_root:prev_commit.data 413 412 with 414 413 | Ok blocks -> 415 - Lwt.return (BlockMap.merge blocks !added_leaves) 414 + Lwt.return (Block_map.merge blocks !added_leaves) 416 415 | Error err -> 417 416 raise err 418 417 in 419 418 let block_stream = 420 - proof_blocks |> BlockMap.entries |> Lwt_seq.of_list 419 + proof_blocks |> Block_map.entries |> Lwt_seq.of_list 421 420 |> Lwt_seq.cons (new_commit_cid, commit_block) 422 421 in 423 422 let%lwt blocks =
+9 -9
pegasus/lib/util.ml
··· 119 119 | _ -> 120 120 Error "invalid field value" 121 121 122 - type string_or_string_map = [`String of string | `StringMap of string_map] 122 + type string_or_string_map = [`String of string | `String_map of string_map] 123 123 124 124 let string_or_string_map_to_yojson = function 125 125 | `String c -> 126 126 `String c 127 - | `StringMap m -> 127 + | `String_map m -> 128 128 `Assoc (List.map (fun (k, v) -> (k, `String v)) m) 129 129 130 130 let string_or_string_map_of_yojson = function 131 131 | `String c -> 132 - Ok (`StringMap [(c, "")]) 132 + Ok (`String_map [(c, "")]) 133 133 | `Assoc m -> 134 134 Ok 135 - (`StringMap 135 + (`String_map 136 136 (List.map (fun (k, v) -> (k, Yojson.Safe.Util.to_string v)) m) ) 137 137 | _ -> 138 138 Error "invalid field value" 139 139 140 140 type string_or_string_map_or_either_list = 141 141 [ `String of string 142 - | `StringMap of string_map 142 + | `String_map of string_map 143 143 | `List of string_or_string_map list ] 144 144 145 145 let string_or_string_map_or_either_list_to_yojson = function 146 146 | `String c -> 147 147 `String c 148 - | `StringMap m -> 148 + | `String_map m -> 149 149 `Assoc (List.map (fun (k, v) -> (k, `String v)) m) 150 150 | `List l -> 151 151 `List (List.map string_or_string_map_to_yojson l) 152 152 153 153 let string_or_string_map_or_either_list_of_yojson = function 154 154 | `String c -> 155 - Ok (`StringMap [(c, "")]) 155 + Ok (`String_map [(c, "")]) 156 156 | `Assoc m -> 157 157 Ok 158 - (`StringMap 158 + (`String_map 159 159 (List.map (fun (k, v) -> (k, Yojson.Safe.Util.to_string v)) m) ) 160 160 | `List l -> 161 161 Ok ··· 281 281 (fun acc (_, value) -> 282 282 match value with `BlobRef blob -> blob :: acc | _ -> acc ) 283 283 [] 284 - (Mist.Lex.StringMap.bindings record) 284 + (Mist.Lex.String_map.bindings record) 285 285 286 286 (* returns whether the value is None *) 287 287 let is_none = function None -> true | _ -> false