From 2a3ffd895f5c2061d7941134bb15df6047141916 Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Thu, 30 Jul 2026 19:55:42 +0000 Subject: B-trees & serialization with bencode --- lib/concepts/Hash.mli | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/concepts/Hash.mli') diff --git a/lib/concepts/Hash.mli b/lib/concepts/Hash.mli index b100cd7..44fb3d0 100644 --- a/lib/concepts/Hash.mli +++ b/lib/concepts/Hash.mli @@ -1,11 +1,32 @@ (** an abstract value representing a hash *) type hash +(** the size of a hash, in bytes *) +val size : int + (** given a value, compute it's hash *) val hash_of_value : Value.value -> hash +(** given a bag of bytes, compute it's hash *) +val hash_of_bytes : bytes -> hash + +(** given a blob, compute it's hash *) +val hash_of_blob : Representation.blob -> hash + +(** given a hash, return a representation of it as a string (/not/ the usual hex representation!) *) +val to_raw_string : hash -> string + +(** given a string containing a representation of a hash (as per `to_raw_string`), return the corresponding hash *) +val of_raw_string : string -> hash + +(** compare two hashes lexicographically *) +val compare : hash -> hash -> Ordering.ordering + (** given two hashes, are they the same? *) val hash_equals : hash -> hash -> bool (** given a hash, return a `bytes` representation of it *) val bytes_of_hash : hash -> bytes + +(** pick one every 1/2^n hashes *) +val pick : int -> hash -> bool -- cgit v1.2.3