aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-08-23 17:03:25 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-08-23 17:03:25 +0000
commit997f3c6c039fd73de26df9f2d2cc1afa9f2677b4 (patch)
tree6c68b4ad213c3de892a5350ea0e46539680966dd
parent4c45f50eb5950d9dfc21fe36839d90c77de13d54 (diff)
downloadRNT-997f3c6c039fd73de26df9f2d2cc1afa9f2677b4.tar.gz
RNT-997f3c6c039fd73de26df9f2d2cc1afa9f2677b4.zip
Ordering is now under Utilities
-rw-r--r--lib/concepts/Hash.ml4
-rw-r--r--lib/concepts/Hash.mli2
-rw-r--r--lib/concepts/Ordering.ml4
-rw-r--r--lib/kernel/Merkle.ml6
4 files changed, 6 insertions, 10 deletions
diff --git a/lib/concepts/Hash.ml b/lib/concepts/Hash.ml
index b2ed4b2..922851a 100644
--- a/lib/concepts/Hash.ml
+++ b/lib/concepts/Hash.ml
@@ -5,7 +5,7 @@ type hash = Digestif.SHA256.t
let size = 256/8
let compare h1 h2 = Digestif.SHA256.unsafe_compare h1 h2
- |> Ordering.of_int
+ |> Utilities.Ordering.of_int
let hash_of_bytes bytes = Digestif.SHA256.digest_bytes bytes
@@ -31,4 +31,4 @@ let power_of_two p =
let pick n hash =
let threshold = Digestif.SHA256.of_raw_string (power_of_two (256 - n)) in
- compare hash threshold = Ordering.Smaller
+ compare hash threshold = Utilities.Ordering.Smaller
diff --git a/lib/concepts/Hash.mli b/lib/concepts/Hash.mli
index 0e71fda..ca50406 100644
--- a/lib/concepts/Hash.mli
+++ b/lib/concepts/Hash.mli
@@ -20,7 +20,7 @@ val of_raw_string : string -> hash
val to_hum_string : hash -> string
(** compare two hashes lexicographically *)
-val compare : hash -> hash -> Ordering.ordering
+val compare : hash -> hash -> Utilities.Ordering.t
(** given two hashes, are they the same? *)
val hash_equals : hash -> hash -> bool
diff --git a/lib/concepts/Ordering.ml b/lib/concepts/Ordering.ml
deleted file mode 100644
index 42b20e5..0000000
--- a/lib/concepts/Ordering.ml
+++ /dev/null
@@ -1,4 +0,0 @@
-type ordering = Equal | Smaller | Greater
-
-let of_int x =
- if x < 0 then Smaller else if x > 0 then Greater else Equal
diff --git a/lib/kernel/Merkle.ml b/lib/kernel/Merkle.ml
index 6172e6f..05adbd2 100644
--- a/lib/kernel/Merkle.ml
+++ b/lib/kernel/Merkle.ml
@@ -8,7 +8,7 @@ end
module type KEY = sig
include VALUE
- val compare : t -> t -> Concepts.Ordering.ordering
+ val compare : t -> t -> Utilities.Ordering.t
end
module type TREE = functor (S : Abstract.Storage.STORAGE) (K : KEY) -> sig
@@ -53,7 +53,7 @@ module Make : TREE = functor (S : Abstract.Storage.STORAGE) (K : KEY) -> struct
let empty = Leaf { keys = BatFingerTree.empty; values = BatFingerTree.empty }
let rec lookup1' keys key bottom top =
- let open Concepts.Ordering in
+ let open Utilities.Ordering in
if bottom >= top then (bottom, false)
else
let mid = bottom + (top - bottom) / 2 in
@@ -389,6 +389,6 @@ module StringKey : KEY with type t = string = struct
type t = string
let encode s = String.to_bytes s |> Concepts.Blob.blob_of_bytes
- let compare s1 s2 = String.compare s1 s2 |> Concepts.Ordering.of_int
+ let compare s1 s2 = String.compare s1 s2 |> Utilities.Ordering.of_int
let decode b = Concepts.Blob.bytes_of_blob b |> String.of_bytes |> Result.ok
end