objective categorical abstract machine language personal data server

Simplify some classes

futur.blue f3d99d91 5865c548

verified
+11 -62
+11 -11
mist/lib/storage/blob_store.ml
··· 1 1 module type S = sig 2 2 type t 3 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 4 + val put_blob : t -> bytes -> Cid.t Lwt.t 13 5 14 6 val get_bytes : t -> Cid.t -> bytes Lwt.t 15 7 16 8 val get_seq : t -> Cid.t -> char Seq.t Lwt.t 17 9 18 - val has_temp : t -> string -> bool Lwt.t 10 + val has : t -> Cid.t -> bool Lwt.t 19 11 20 - val has_stored : t -> Cid.t -> bool Lwt.t 12 + val list : t -> Cid.t list Lwt.t 21 13 22 14 val delete : t -> Cid.t -> unit Lwt.t 23 15 24 16 val delete_many : t -> Cid.t list -> unit Lwt.t 17 + 18 + val list_refs : t -> path:string -> Cid.t list Lwt.t 19 + 20 + val add_ref : t -> path:string -> Cid.t -> unit Lwt.t 21 + 22 + val delete_ref : t -> path:string -> Cid.t -> unit Lwt.t 23 + 24 + val recount_refs : t -> Cid.t -> unit Lwt.t 25 25 end
-22
mist/lib/storage/memory_store.ml
··· 1 - open Lwt.Infix 2 - 3 1 module Make () = struct 4 2 type t = 5 3 { mutable blocks: Block_map.t ··· 13 11 let has s cid = Lwt.return (Block_map.has cid s.blocks) 14 12 15 13 let get_blocks s cids = Lwt.return (Block_map.get_many cids s.blocks) 16 - 17 - let read_obj_and_bytes s cid = 18 - get_bytes s cid 19 - >|= function 20 - | Some b -> 21 - let v = Dag_cbor.decode b in 22 - Some (v, b) 23 - | None -> 24 - None 25 - 26 - let read_obj s cid = read_obj_and_bytes s cid >|= Option.map fst 27 - 28 - let read_record s cid = 29 - match Block_map.get cid s.blocks with 30 - | Some b -> 31 - Lwt.return (Lex.of_cbor b) 32 - | None -> 33 - raise (Failure "Missing block") 34 - 35 - let get_root s = Lwt.return s.root 36 14 37 15 let put_block s cid bytes ~rev = 38 16 s.blocks <- Block_map.set cid bytes s.blocks ;
-21
mist/lib/storage/overlay_store.ml
··· 30 30 let* from_bottom = Bottom.get_blocks bottom from_top.missing in 31 31 let merged_blocks = Block_map.merge from_top.blocks from_bottom.blocks in 32 32 Lwt.return {Block_map.blocks= merged_blocks; missing= from_bottom.missing} 33 - 34 - let read_obj_and_bytes {top; bottom} cid = 35 - let* from_top = Top.read_obj_and_bytes top cid in 36 - match from_top with 37 - | Some _ as res -> 38 - Lwt.return res 39 - | None -> 40 - Bottom.read_obj_and_bytes bottom cid 41 - 42 - let read_obj {top; bottom} cid = 43 - let* from_top = Top.read_obj top cid in 44 - match from_top with 45 - | Some _ as res -> 46 - Lwt.return res 47 - | None -> 48 - Bottom.read_obj bottom cid 49 - 50 - let read_record {top; bottom} cid = 51 - Lwt.catch 52 - (fun () -> Top.read_record top cid) 53 - (fun _ -> Bottom.read_record bottom cid) 54 33 end
-8
mist/lib/storage/repo_store.ml
··· 14 14 val has : t -> Cid.t -> bool Lwt.t 15 15 16 16 val get_blocks : t -> Cid.t list -> Block_map.with_missing Lwt.t 17 - 18 - val read_obj_and_bytes : t -> Cid.t -> (Dag_cbor.value * bytes) option Lwt.t 19 - 20 - val read_obj : t -> Cid.t -> Dag_cbor.value option Lwt.t 21 - 22 - val read_record : t -> Cid.t -> Lex.repo_record Lwt.t 23 17 end 24 18 25 19 module type Writable = sig 26 20 type t 27 21 28 22 include Readable with type t := t 29 - 30 - val get_root : t -> Cid.t option Lwt.t 31 23 32 24 val put_block : t -> Cid.t -> bytes -> rev:string -> unit Lwt.t 33 25