aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Addressable.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-09-19 01:08:28 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-09-19 01:09:24 +0000
commit2e2d7f6a9b116dac2fa20be657c916cb498c1508 (patch)
tree94d39b1c49f69d1ca851e6e53b80297e603546bf /lib/protocols/Addressable.ml
parentc80121c23a90c60b9975e04a49d98c8dfb4866a1 (diff)
downloadRNT-2e2d7f6a9b116dac2fa20be657c916cb498c1508.tar.gz
RNT-2e2d7f6a9b116dac2fa20be657c916cb498c1508.zip
Do not assume that the hash of an object is its storage address
Diffstat (limited to '')
-rw-r--r--lib/protocols/Addressable.ml13
-rw-r--r--lib/protocols/Addressable.mli11
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/protocols/Addressable.ml b/lib/protocols/Addressable.ml
new file mode 100644
index 0000000..7e97f08
--- /dev/null
+++ b/lib/protocols/Addressable.ml
@@ -0,0 +1,13 @@
+class type implementation = object
+ method address : Concepts.Hash.hash
+end
+
+type Handle.protocol += Addressable of implementation
+
+type t = implementation
+
+let make impl = Addressable (impl :> implementation)
+
+let from handle = Handle.into handle (function Addressable impl -> Some impl | _ -> None)
+
+let address i = Handle.invoke i (fun o -> o#address)
diff --git a/lib/protocols/Addressable.mli b/lib/protocols/Addressable.mli
new file mode 100644
index 0000000..2d9c14d
--- /dev/null
+++ b/lib/protocols/Addressable.mli
@@ -0,0 +1,11 @@
+type t
+
+class type implementation = object
+ method address : Concepts.Hash.hash
+end
+
+val make : #implementation -> Handle.protocol
+
+val from : Handle.t -> t Handle.interface option
+
+val address : t Handle.interface -> Concepts.Hash.hash