Nodes
A node is a process runningstellarium-ts. It does three things:
- Hosts internal resources: the functions you register with
node.register(), which run in your process. - Remembers external resources and peers it has learned about from other nodes. These are stored in
requestscript.db, a SQLite file created in the working directory on startup. - Runs RequestScript requests submitted to
POST /v1/run, calling resources locally or forwarding them to the peer that hosts them.
Resources
A resource is a named set of functions.path and name together form its fully qualified name, such as com.example.Weather. Each function declares its RequestScript parameter types and return type.
path, name, baseUrl, and function signatures (name, returnType, parameters, and any paymentManifest). Function implementations never leave the node that hosts them.
A function can optionally carry a payment manifest that sets its price. See Payments.
Requests
A RequestScriptrequest binds resources with const <name>: <path>.<ResourceName> and calls their functions with named arguments:
- If
com.example.Weatheris registered on this process, itsexecruns locally. - If it was learned from a peer, the node forwards the call to that peer’s
{baseUrl}/v1/run/resourceand returns the result.
Joining a network
PassstartingPeer to node.start() to bootstrap from a node that is already running. Once the node is listening, it:
1
Copies the peer list
GET {startingPeer}/v1/peers. If this node has no peers yet, it stores the returned list, plus the starting peer itself (from GET {startingPeer}/v1/self). An existing list is left as-is.2
Copies the resource list
GET {startingPeer}/v1/resources. Each resource is stored with the baseUrl that peer advertised.3
Announces itself
Sends a signed
PUT /v1/peers to every known peer with its baseUrl and public key.4
Broadcasts its resources
Sends a signed
PUT /v1/all-resources to every known peer with its internal resources.SIGNING_PRIVATE_KEY and expire after 10 minutes. Receiving nodes verify the signature against the sender’s public key and reject expired or invalid payloads.