REST: node control
Four endpoints at the root of the interface tell what the node is doing and shut it down. They are part of the REST interface and need the bearer token like every other endpoint.
GET /height
The height of the chain that the sporks mint on. Until the node follows that chain, the tip of the legacy chain snapshot stands in for it.
| Answer | Meaning |
|---|---|
| 200 | {"height": <number>} |
| 503 | The node holds no snapshot, so there is no height |
GET /status
What the node is busy with. A daemon that starts without a snapshot it can open downloads one in the background, and reports its progress here.
| Field | Meaning |
|---|---|
status |
running, downloading or failed |
progress |
A percentage, 100 while running, and null while the size of a download is not known |
message |
Why a download failed; null otherwise |
The answer is always 200. A failed download leaves the node running and is tried again after 10 seconds, then after
twice the previous pause each time, up to 10 minutes. Between two attempts status is failed and message holds
the reason. An attempt that finds a snapshot the node can open, such as one that hedgehog bootstrap fetch brought
in the meantime, sets running without a download; any other attempt reports downloading again, and running
once its download succeeds.
GET /version
Answers 200 with version, the version of the program, and protocols, the protocol names the node offers its
peers, in the order it offers them: hedgehog-ledger/0.0.2 when the node runs the ledger, then
hedgehog-proxy/0.0.2 when it runs with --preview, then hedgehog/0.0.9, hedgehog/0.0.4 and
gridspork/0.0.4. See
Peer-to-peer network protocol.
POST /stop
Answers 202 and then shuts the node down. The shutdown begins once the answer is written to the connection, or once its write has failed. A caller that does not read the answer, or is gone, holds the node up for two seconds at the most. A stop that arrives while the node is still starting is kept, and the node shuts down as soon as it has started.
In the source
application/src/main/java/org/unigrid/hedgehog/server/rest/UtilResource.java: the four endpoints.application/src/main/java/org/unigrid/hedgehog/server/rest/StopAfterAnswer.java: begins the shutdown once the answer to/stopis written.application/src/main/java/org/unigrid/hedgehog/model/NodeStatus.java: the status of the node.application/src/main/java/org/unigrid/hedgehog/server/rest/entity/VersionResponse.java: the version answer.