objective categorical abstract machine language personal data server
65
fork

Configure Feed

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

Repo storage & blob store interface

futurGH 36a28a5e 26b124ac

+114 -95
+6
ipld/lib/cid.ml
··· 147 147 let equal a b = String.equal (to_string a) (to_string b) 148 148 149 149 let hash = Hashtbl.hash 150 + 151 + module Set = Set.Make (struct 152 + type nonrec t = t 153 + 154 + let compare = compare 155 + end)
-95
mist/lib/block_map.ml
··· 1 - module Cid_map = Map.Make (Cid) 2 - 3 - module type S = sig 4 - type t 5 - 6 - type many = {blocks: t; missing: Cid.t list} 7 - 8 - val add : Lex.value -> Cid.t 9 - 10 - val update : Cid.t -> bytes -> unit 11 - 12 - val find : Cid.t -> bytes option 13 - 14 - val remove : Cid.t -> unit 15 - 16 - val find_many : Cid.t list -> many 17 - 18 - val mem : Cid.t -> bool 19 - 20 - val clear : unit -> unit 21 - 22 - val iter : (Cid.t -> bytes -> unit) -> unit 23 - 24 - val to_list : (Cid.t * bytes) list 25 - 26 - val to_seq : (Cid.t * bytes) Seq.t 27 - 28 - val cids : Cid.t list 29 - 30 - val add_map : t -> t 31 - 32 - val cardinal : unit -> int 33 - 34 - val byte_size : unit -> int 35 - 36 - val equal : t -> bool 37 - end 38 - 39 - module Make : S = struct 40 - type t = bytes Cid_map.t 41 - 42 - type many = {blocks: t; missing: Cid.t list} 43 - 44 - let map : bytes Cid_map.t ref = ref Cid_map.empty 45 - 46 - let add value = 47 - let cid, bytes = Lex.to_cbor_block value in 48 - map := Cid_map.add cid bytes !map ; 49 - cid 50 - 51 - let update cid bytes = map := Cid_map.add cid bytes !map 52 - 53 - let find cid = Cid_map.find_opt cid !map 54 - 55 - let remove cid = 56 - map := Cid_map.remove cid !map ; 57 - () 58 - 59 - let find_many cids = 60 - let blocks = Cid_map.empty in 61 - let missing = ref [] in 62 - List.iter 63 - (fun cid -> 64 - match Cid_map.find_opt cid !map with 65 - | Some bytes -> 66 - ignore (Cid_map.add cid bytes blocks) 67 - | None -> 68 - missing := cid :: !missing ) 69 - cids ; 70 - {blocks; missing= List.rev !missing} 71 - 72 - let mem cid = Cid_map.mem cid !map 73 - 74 - let clear () = 75 - Cid_map.iter (fun cid _ -> remove cid) !map ; 76 - () 77 - 78 - let iter f = Cid_map.iter (fun cid bytes -> f cid bytes) !map 79 - 80 - let to_list = Cid_map.bindings !map 81 - 82 - let to_seq = Cid_map.to_seq !map 83 - 84 - let cids = Cid_map.fold (fun cid _ acc -> cid :: acc) !map [] 85 - 86 - let add_map t = 87 - Cid_map.fold (fun cid bytes acc -> Cid_map.add cid bytes acc) t !map 88 - 89 - let cardinal () = Cid_map.cardinal !map 90 - 91 - let byte_size () = 92 - Cid_map.fold (fun _ bytes acc -> acc + Bytes.length bytes) !map 0 93 - 94 - let equal t = Cid_map.equal ( = ) !map t 95 - end
+2
mist/lib/dune
··· 2 2 (name mist) 3 3 (libraries digestif ipld lwt multihash str yojson ppx_deriving_yojson.runtime) 4 4 (preprocess (pps ppx_deriving_yojson))) 5 + 6 + (include_subdirs qualified)
+25
mist/lib/storage/blob_store.ml
··· 1 + module type S = sig 2 + type t 3 + 4 + val put_temp : t -> char Seq.t -> string Lwt.t 5 + 6 + val make_permanent : t -> string -> Cid.t -> unit Lwt.t 7 + 8 + val put_permanent : t -> Cid.t -> char Seq.t -> unit Lwt.t 9 + 10 + val quarantine : t -> Cid.t -> unit Lwt.t 11 + 12 + val unquarantine : t -> Cid.t -> unit Lwt.t 13 + 14 + val get_bytes : t -> Cid.t -> bytes Lwt.t 15 + 16 + val get_seq : t -> Cid.t -> char Seq.t Lwt.t 17 + 18 + val has_temp : t -> string -> bool Lwt.t 19 + 20 + val has_stored : t -> Cid.t -> bool Lwt.t 21 + 22 + val delete : t -> Cid.t -> unit Lwt.t 23 + 24 + val delete_many : t -> Cid.t list -> unit Lwt.t 25 + end
+46
mist/lib/storage/block_map.ml
··· 1 + module Cid_map = Map.Make (Cid) 2 + 3 + type t = bytes Cid_map.t 4 + 5 + type with_missing = {blocks: t; missing: Cid.t list} 6 + 7 + let empty = Cid_map.empty 8 + 9 + let add m value = 10 + let cid, bytes = Lex.to_cbor_block value in 11 + (Cid_map.add cid bytes m, cid) 12 + 13 + let set m cid bytes = Cid_map.add cid bytes m 14 + 15 + let get m cid = Cid_map.find_opt cid m 16 + 17 + let remove m cid = Cid_map.remove cid m 18 + 19 + let get_many m cids = 20 + let blocks, missing = 21 + List.fold_left 22 + (fun (b, mis) cid -> 23 + match get m cid with 24 + | Some bytes -> 25 + (Cid_map.add cid bytes b, mis) 26 + | None -> 27 + (b, mis @ [cid]) ) 28 + (Cid_map.empty, []) cids 29 + in 30 + {blocks; missing= List.rev missing} 31 + 32 + let has = Cid_map.mem 33 + 34 + let iter = Cid_map.iter 35 + 36 + let entries = Cid_map.bindings 37 + 38 + let merge m m' = 39 + let m = Cid_map.fold (fun cid bytes m -> Cid_map.add cid bytes m) m m in 40 + Cid_map.fold (fun cid bytes m -> Cid_map.add cid bytes m) m' m 41 + 42 + let size = Cid_map.cardinal 43 + 44 + let byte_size m = Cid_map.fold (fun _ bytes acc -> acc + Bytes.length bytes) m 0 45 + 46 + let equal = Cid_map.equal Bytes.equal
+35
mist/lib/storage/storage.ml
··· 1 + module Block_map = Block_map 2 + 3 + type commit_data = 4 + { cid: Cid.t 5 + ; rev: string 6 + ; since: string option 7 + ; prev: Cid.t option 8 + ; relevant_blocks: Block_map.t 9 + ; removed_cids: Cid.Set.t } 10 + 11 + module type S = sig 12 + type t 13 + 14 + val get_root : t -> Cid.t option Lwt.t 15 + 16 + val put_block : t -> Cid.t -> bytes -> rev:string -> unit Lwt.t 17 + 18 + val put_many : t -> Block_map.t -> unit Lwt.t 19 + 20 + val update_root : t -> Cid.t -> rev:string -> unit Lwt.t 21 + 22 + val apply_commit : t -> commit_data -> unit Lwt.t 23 + 24 + val get_bytes : t -> Cid.t -> bytes option Lwt.t 25 + 26 + val has : t -> Cid.t -> bool Lwt.t 27 + 28 + val get_blocks : t -> Cid.t list -> Block_map.with_missing Lwt.t 29 + 30 + val read_obj_and_bytes : t -> Cid.t -> (Dag_cbor.value * bytes) option Lwt.t 31 + 32 + val read_obj : t -> Cid.t -> Dag_cbor.value option Lwt.t 33 + 34 + val read_record : t -> Cid.t -> Lex.repo_record 35 + end