From 8f87d272038ddea11c366d9a14079666daf6628b Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Sun, 23 Aug 2026 03:52:08 +0000 Subject: The branch manager should persist changes to the root --- lib/concepts/Hash.ml | 5 ++++- lib/concepts/Hash.mli | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/concepts') diff --git a/lib/concepts/Hash.ml b/lib/concepts/Hash.ml index ae0a178..b2ed4b2 100644 --- a/lib/concepts/Hash.ml +++ b/lib/concepts/Hash.ml @@ -11,6 +11,10 @@ let hash_of_bytes bytes = Digestif.SHA256.digest_bytes bytes let hash_of_blob blob = Blob.bytes_of_blob blob |> Digestif.SHA256.digest_bytes +let bytes_of_hash (h : hash) = Bytes.of_string (Digestif.SHA256.to_raw_string h) + +let blob_of_hash h = bytes_of_hash h |> Blob.blob_of_bytes + let to_raw_string hash = Digestif.SHA256.to_raw_string hash let of_raw_string str = Digestif.SHA256.of_raw_string str @@ -18,7 +22,6 @@ let of_raw_string str = Digestif.SHA256.of_raw_string str let to_hum_string hash = Digestif.SHA256.to_hex hash let hash_equals = Digestif.SHA256.equal -let bytes_of_hash (h : hash) = Bytes.of_string (Digestif.SHA256.to_raw_string h) let power_of_two p = let b = Bytes.make 32 '\x00' in diff --git a/lib/concepts/Hash.mli b/lib/concepts/Hash.mli index b3ae2dc..0e71fda 100644 --- a/lib/concepts/Hash.mli +++ b/lib/concepts/Hash.mli @@ -28,5 +28,8 @@ val hash_equals : hash -> hash -> bool (** given a hash, return a `bytes` representation of it *) val bytes_of_hash : hash -> bytes +(** given a hash, return a `blob` representation of it *) +val blob_of_hash : hash -> Blob.t + (** pick one every 1/2^n hashes *) val pick : int -> hash -> bool -- cgit v1.2.3