···11module type S = sig
22 type t
3344- val put_temp : t -> char Seq.t -> string Lwt.t
55-66- val make_permanent : t -> string -> Cid.t -> unit Lwt.t
77-88- val put_permanent : t -> Cid.t -> char Seq.t -> unit Lwt.t
99-1010- val quarantine : t -> Cid.t -> unit Lwt.t
1111-1212- val unquarantine : t -> Cid.t -> unit Lwt.t
44+ val put_blob : t -> bytes -> Cid.t Lwt.t
135146 val get_bytes : t -> Cid.t -> bytes Lwt.t
157168 val get_seq : t -> Cid.t -> char Seq.t Lwt.t
1791818- val has_temp : t -> string -> bool Lwt.t
1010+ val has : t -> Cid.t -> bool Lwt.t
19112020- val has_stored : t -> Cid.t -> bool Lwt.t
1212+ val list : t -> Cid.t list Lwt.t
21132214 val delete : t -> Cid.t -> unit Lwt.t
23152416 val delete_many : t -> Cid.t list -> unit Lwt.t
1717+1818+ val list_refs : t -> path:string -> Cid.t list Lwt.t
1919+2020+ val add_ref : t -> path:string -> Cid.t -> unit Lwt.t
2121+2222+ val delete_ref : t -> path:string -> Cid.t -> unit Lwt.t
2323+2424+ val recount_refs : t -> Cid.t -> unit Lwt.t
2525end
-22
mist/lib/storage/memory_store.ml
···11-open Lwt.Infix
22-31module Make () = struct
42 type t =
53 { mutable blocks: Block_map.t
···1311 let has s cid = Lwt.return (Block_map.has cid s.blocks)
14121513 let get_blocks s cids = Lwt.return (Block_map.get_many cids s.blocks)
1616-1717- let read_obj_and_bytes s cid =
1818- get_bytes s cid
1919- >|= function
2020- | Some b ->
2121- let v = Dag_cbor.decode b in
2222- Some (v, b)
2323- | None ->
2424- None
2525-2626- let read_obj s cid = read_obj_and_bytes s cid >|= Option.map fst
2727-2828- let read_record s cid =
2929- match Block_map.get cid s.blocks with
3030- | Some b ->
3131- Lwt.return (Lex.of_cbor b)
3232- | None ->
3333- raise (Failure "Missing block")
3434-3535- let get_root s = Lwt.return s.root
36143715 let put_block s cid bytes ~rev =
3816 s.blocks <- Block_map.set cid bytes s.blocks ;
-21
mist/lib/storage/overlay_store.ml
···3030 let* from_bottom = Bottom.get_blocks bottom from_top.missing in
3131 let merged_blocks = Block_map.merge from_top.blocks from_bottom.blocks in
3232 Lwt.return {Block_map.blocks= merged_blocks; missing= from_bottom.missing}
3333-3434- let read_obj_and_bytes {top; bottom} cid =
3535- let* from_top = Top.read_obj_and_bytes top cid in
3636- match from_top with
3737- | Some _ as res ->
3838- Lwt.return res
3939- | None ->
4040- Bottom.read_obj_and_bytes bottom cid
4141-4242- let read_obj {top; bottom} cid =
4343- let* from_top = Top.read_obj top cid in
4444- match from_top with
4545- | Some _ as res ->
4646- Lwt.return res
4747- | None ->
4848- Bottom.read_obj bottom cid
4949-5050- let read_record {top; bottom} cid =
5151- Lwt.catch
5252- (fun () -> Top.read_record top cid)
5353- (fun _ -> Bottom.read_record bottom cid)
5433end
-8
mist/lib/storage/repo_store.ml
···1414 val has : t -> Cid.t -> bool Lwt.t
15151616 val get_blocks : t -> Cid.t list -> Block_map.with_missing Lwt.t
1717-1818- val read_obj_and_bytes : t -> Cid.t -> (Dag_cbor.value * bytes) option Lwt.t
1919-2020- val read_obj : t -> Cid.t -> Dag_cbor.value option Lwt.t
2121-2222- val read_record : t -> Cid.t -> Lex.repo_record Lwt.t
2317end
24182519module type Writable = sig
2620 type t
27212822 include Readable with type t := t
2929-3030- val get_root : t -> Cid.t option Lwt.t
31233224 val put_block : t -> Cid.t -> bytes -> rev:string -> unit Lwt.t
3325