sbn contract

This commit is contained in:
Peter Harpending
2026-12-04 11:03:04 -08:00
parent 23ec148c18
commit 5997431690
7 changed files with 166 additions and 147 deletions
-15
View File
@@ -1,15 +0,0 @@
contract interface Rubicon =
entrypoint lookup: () => list(string * int * string * string * address * bytes)
contract Names =
type rbx_tuple = string * int * string * string * address * bytes
type state = map(string, Rubicon)
entrypoint init(): state =
{}
stateful entrypoint register(name: string, addr: Rubicon): unit =
put(state{[name] = addr})
stateful entrypoint lookup(name: string): list(rbx_tuple) =
Map.lookup(name, state)
+31
View File
@@ -0,0 +1,31 @@
contract Sbn =
record sp =
{ip : string,
port : int,
protocol : string, // "tcp", "udp", "sctp", etc
noise : string, // Noise_Foo_Bar_Baz_Quux
pubkey : address, // responder static pubkey (noise: rs field)
prologue : bytes} // noise prologue (empty = no prologue)
type state = map(string, list(sp))
entrypoint
init : () => state
init() = {}
stateful entrypoint
register : (string, list(sp)) => bool
register(name, roster) =
put(state{[name] = roster})
true
stateful entrypoint
lookup : (string) => option(list(rp))
lookup(name) =
Map.lookup(name, state)
stateful entrypoint
get_state : state
get_state() =
state