···3333 | [ _algo; hex ] -> hex
3434 | _ -> Ohex.encode subject
35353636-let make_repo_key subject =
3636+let repo_key subject =
3737 let rkey = subject_to_rkey subject in
3838 collection ^ "/" ^ rkey
3939···108108 The proof is a sparse tree containing only the nodes traversed during
109109 the key lookup. Blinded subtrees are replaced by their CID. The
110110 serialized proof goes in the receipt's [vdp] (396) unprotected header,
111111- enabling fully offline verification via
112112- [Irmin.Private.Proof.Mst.verify]. *)
111111+ enabling fully offline verification via [Irmin.Proof.Mst.verify]. *)
113112 let compute_proof t ~key repo_key =
114113 let root_cid = Atp.Mst.to_cid t.mst ~store:C.store in
115114 let leaf_hash =
···119118 in
120119 (* Produce an Irmin proof for the MST lookup *)
121120 let irmin_proof, _found =
122122- Irmin.Private.Proof.Mst.produce irmin root_cid (fun tree ->
123123- let v = Irmin.Private.Proof.Mst.Tree.find tree [ repo_key ] in
121121+ Irmin.Proof.Mst.produce irmin root_cid (fun tree ->
122122+ let v = Irmin.Proof.Mst.Tree.find tree [ repo_key ] in
124123 (tree, v))
125124 in
126125 (* Serialize: [repo_key, irmin_proof_cbor] packed as CBOR array.
127126 The verifier needs the repo_key to replay the exact lookup. *)
128127 let irmin_proof_cbor =
129129- Irmin.Private.Proof.encode_cbor ~encode_hash:Atp.Cid.to_raw_bytes
128128+ Irmin.Proof.encode_cbor ~encode_hash:Atp.Cid.to_raw_bytes
130129 ~encode_contents:Fun.id irmin_proof
131130 in
132131 let vdp =
···142141 leaf_hash;
143142 }
144143144144+ let err_duplicate key = Error ("duplicate key: " ^ key)
145145+ let err_encoding e = Error ("encoding error: " ^ e)
146146+145147 let append t ~key ~value =
146146- if Hashtbl.mem t.values key then Error (Fmt.str "duplicate key: %s" key)
148148+ if Hashtbl.mem t.values key then err_duplicate key
147149 else
148148- let repo_key = make_repo_key key in
150150+ let repo_key = repo_key key in
149151 match value_to_cid ~key value with
150150- | Error e -> Error (Fmt.str "encoding error: %s" e)
152152+ | Error e -> err_encoding e
151153 | Ok cid ->
152154 Hashtbl.replace t.values key value;
153155 t.mst <- Atp.Mst.add repo_key cid t.mst ~store:C.store;