Skip to main content

Nodes

A node is a process running stellarium-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.
When a node shares its resources, it publishes each resource’s 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 RequestScript request binds resources with const <name>: <path>.<ResourceName> and calls their functions with named arguments:
When a node runs this:
  • If com.example.Weather is registered on this process, its exec runs locally.
  • If it was learned from a peer, the node forwards the call to that peer’s {baseUrl}/v1/run/resource and returns the result.
See the RequestScript repository for the full language.

Joining a network

Pass startingPeer 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.
Announcements are signed with the node’s Ed25519 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.
Omit startingPeer to run a standalone node, for example the first node in a new network.