-1
examples/feed_generator/dune
-1
examples/feed_generator/dune
+8
-1
lib/api/dune
+8
-1
lib/api/dune
+8
-1
lib/crypto/dune
+8
-1
lib/crypto/dune
+11
-2
lib/xrpc/dune
+11
-2
lib/xrpc/dune
+37
-37
test/mst/debug_mst.ml
+37
-37
test/mst/debug_mst.ml
···
2
open Atproto_mst
3
open Atproto_ipld
4
5
-
let leaf_value = match Cid.of_string "bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454" with
6
| Ok cid -> cid
7
| Error _ -> failwith "Invalid CID"
8
9
-
let keys = [
10
-
"A0/374913";
11
-
"B1/986427";
12
-
"C0/451630";
13
-
"E0/670489";
14
-
"F1/085263";
15
-
"G0/765327";
16
-
]
17
18
let () =
19
Printf.printf "=== MST Debug ===\n\n";
20
-
21
(* Print key heights *)
22
Printf.printf "Key heights:\n";
23
-
List.iter (fun k ->
24
-
Printf.printf " %-15s -> height %d\n" k (key_height k)
25
-
) keys;
26
-
27
let store = Memory_blockstore.create () in
28
-
let module M = Make(Memory_blockstore) in
29
-
30
(* Build MST *)
31
let entries = List.map (fun k -> (k, leaf_value)) keys in
32
let root = M.of_entries store entries in
33
-
34
Printf.printf "\nRoot CID: %s\n" (Cid.to_string root);
35
-
Printf.printf "Expected: bafyreicraprx2xwnico4tuqir3ozsxpz46qkcpox3obf5bagicqwurghpy\n";
36
-
37
(* Dump the encoded node *)
38
let blocks = Memory_blockstore.blocks store in
39
Printf.printf "\n%d blocks in store:\n" (List.length blocks);
40
-
List.iter (fun (cid, data) ->
41
-
Printf.printf "\nCID: %s\n" (Cid.to_string cid);
42
-
Printf.printf " Raw bytes (%d): " (String.length data);
43
-
String.iter (fun c -> Printf.printf "%02x" (Char.code c)) data;
44
-
Printf.printf "\n";
45
-
match decode_node_raw data with
46
-
| Ok node ->
47
-
Printf.printf " Left: %s\n"
48
-
(match node.l with Some c -> Cid.to_string c | None -> "None");
49
-
Printf.printf " Entries (%d):\n" (List.length node.e);
50
-
List.iter (fun e ->
51
-
Printf.printf " p=%d k=%S v=%s t=%s\n"
52
-
e.p e.k (Cid.to_string e.v)
53
-
(match e.t with Some c -> Cid.to_string c | None -> "None")
54
-
) node.e
55
-
| Error (`Decode_error msg) ->
56
-
Printf.printf " DECODE ERROR: %s\n" msg
57
-
) blocks
···
2
open Atproto_mst
3
open Atproto_ipld
4
5
+
let leaf_value =
6
+
match
7
+
Cid.of_string "bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454"
8
+
with
9
| Ok cid -> cid
10
| Error _ -> failwith "Invalid CID"
11
12
+
let keys =
13
+
[
14
+
"A0/374913"; "B1/986427"; "C0/451630"; "E0/670489"; "F1/085263"; "G0/765327";
15
+
]
16
17
let () =
18
Printf.printf "=== MST Debug ===\n\n";
19
+
20
(* Print key heights *)
21
Printf.printf "Key heights:\n";
22
+
List.iter
23
+
(fun k -> Printf.printf " %-15s -> height %d\n" k (key_height k))
24
+
keys;
25
+
26
let store = Memory_blockstore.create () in
27
+
let module M = Make (Memory_blockstore) in
28
(* Build MST *)
29
let entries = List.map (fun k -> (k, leaf_value)) keys in
30
let root = M.of_entries store entries in
31
+
32
Printf.printf "\nRoot CID: %s\n" (Cid.to_string root);
33
+
Printf.printf
34
+
"Expected: bafyreicraprx2xwnico4tuqir3ozsxpz46qkcpox3obf5bagicqwurghpy\n";
35
+
36
(* Dump the encoded node *)
37
let blocks = Memory_blockstore.blocks store in
38
Printf.printf "\n%d blocks in store:\n" (List.length blocks);
39
+
List.iter
40
+
(fun (cid, data) ->
41
+
Printf.printf "\nCID: %s\n" (Cid.to_string cid);
42
+
Printf.printf " Raw bytes (%d): " (String.length data);
43
+
String.iter (fun c -> Printf.printf "%02x" (Char.code c)) data;
44
+
Printf.printf "\n";
45
+
match decode_node_raw data with
46
+
| Ok node ->
47
+
Printf.printf " Left: %s\n"
48
+
(match node.l with Some c -> Cid.to_string c | None -> "None");
49
+
Printf.printf " Entries (%d):\n" (List.length node.e);
50
+
List.iter
51
+
(fun e ->
52
+
Printf.printf " p=%d k=%S v=%s t=%s\n" e.p e.k
53
+
(Cid.to_string e.v)
54
+
(match e.t with Some c -> Cid.to_string c | None -> "None"))
55
+
node.e
56
+
| Error (`Decode_error msg) -> Printf.printf " DECODE ERROR: %s\n" msg)
57
+
blocks
+8
-1
test/repo/dune
+8
-1
test/repo/dune