atproto libraries implementation in ocaml

ocamlformat lint

Changed files
+78 -44
examples
feed_generator
lib
api
crypto
xrpc
test
mst
repo
xrpc
-1
examples/feed_generator/dune
··· 14 mirage-crypto-rng.unix 15 base64 16 cstruct)) 17 -
··· 14 mirage-crypto-rng.unix 15 base64 16 cstruct))
+8 -1
lib/api/dune
··· 1 (library 2 (name atproto_api) 3 (public_name atproto-api) 4 - (libraries atproto_syntax atproto_xrpc atproto_identity atproto_ipld atproto_json uri unix))
··· 1 (library 2 (name atproto_api) 3 (public_name atproto-api) 4 + (libraries 5 + atproto_syntax 6 + atproto_xrpc 7 + atproto_identity 8 + atproto_ipld 9 + atproto_json 10 + uri 11 + unix))
+8 -1
lib/crypto/dune
··· 1 (library 2 (name atproto_crypto) 3 (public_name atproto-crypto) 4 - (libraries atproto_multibase mirage-crypto-ec mirage-crypto-rng digestif zarith base64 atproto_json) 5 (preprocess no_preprocessing))
··· 1 (library 2 (name atproto_crypto) 3 (public_name atproto-crypto) 4 + (libraries 5 + atproto_multibase 6 + mirage-crypto-ec 7 + mirage-crypto-rng 8 + digestif 9 + zarith 10 + base64 11 + atproto_json) 12 (preprocess no_preprocessing))
+11 -2
lib/xrpc/dune
··· 1 (library 2 (name atproto_xrpc) 3 (public_name atproto-xrpc) 4 - (libraries atproto_effects atproto_syntax atproto_lexicon atproto_json uri 5 - mirage-crypto-rng digestif base64 cstruct unix))
··· 1 (library 2 (name atproto_xrpc) 3 (public_name atproto-xrpc) 4 + (libraries 5 + atproto_effects 6 + atproto_syntax 7 + atproto_lexicon 8 + atproto_json 9 + uri 10 + mirage-crypto-rng 11 + digestif 12 + base64 13 + cstruct 14 + unix))
+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
··· 1 (test 2 (name test_repo) 3 (package atproto-repo) 4 - (libraries atproto-repo atproto-crypto atproto-ipld atproto-mst atproto-syntax mirage-crypto-rng.unix alcotest))
··· 1 (test 2 (name test_repo) 3 (package atproto-repo) 4 + (libraries 5 + atproto-repo 6 + atproto-crypto 7 + atproto-ipld 8 + atproto-mst 9 + atproto-syntax 10 + mirage-crypto-rng.unix 11 + alcotest))
+6 -1
test/xrpc/dune
··· 1 (test 2 (name test_xrpc) 3 - (libraries atproto_xrpc atproto_syntax atproto_json alcotest mirage-crypto-rng.unix))
··· 1 (test 2 (name test_xrpc) 3 + (libraries 4 + atproto_xrpc 5 + atproto_syntax 6 + atproto_json 7 + alcotest 8 + mirage-crypto-rng.unix))