This commit is contained in:
Peter Harpending
2026-09-03 15:47:09 -07:00
parent 66364fce04
commit edf2030b34
10 changed files with 92 additions and 28 deletions
+11 -24
View File
@@ -4,41 +4,28 @@
* Author: Peter Harpending <peterharpending@qpq.swiss>
* Date: 2026-08-12
*/
contract Rubicon =
// this could/should be a record, but records aren't really
// portable across contracts/languages/APIs
//
// I think records are returned to caller as a FATE tuple with
// fields in this order. I don't really know though and that's
// kind of a hack and not something that we should build around i
// feel like
//
// record rbx =
// {ip : string,
// port : int,
// protocol : string, // "tcp", "udp", "sctp", etc
// noise : string, // Noise_Foo_Bar_Baz_Quux
// pubkey : bytes, // service's pubkey
// salt : bytes} // ???
// pubkey : bytes, // responder static pubkey (noise rs field)
// prologue : bytes} // noise prologue (empty = no prologue)
// (ip, port, protocol, noise, pubkey)
type rbx_tuple = string * int * string * string * bytes
// (ip, port, protocol, noise, pubkey, prologue)
type rbx_tuple = string * int * string * string * bytes * bytes
type state = list(rbx_tuple)
entrypoint
init : list(rbx_tuple) => state
init(services) =
services
entrypoint init(tuples: list(rbx_tuple)): state =
tuples
stateful entrypoint
set_services : list(rbx_tuple) => ()
set_services(_) | Call.caller != Contract.creator =
abort("Not allowed")
set_services(svs) =
put(svs)
stateful entrypoint set(tuples: list(rbx_tuple)): unit =
require(Call.caller == Contract.creator, "Not allowed")
put(tuples)
entrypoint
get_services : () => list(rbx_tuple)
get_services() =
state
entrypoint lookup(): list(rbx_tuple) =
state