sbn contract
This commit is contained in:
@@ -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)
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user