Global Sync access (#994)

* Connect sync logic to network globals

* Add further sync info to sync status

* Build new syncing HTTP API methods

* Fix bug in updating sync state

* Highest slot is current slot

* Update book for syncing API
This commit is contained in:
Age Manning
2020-04-14 18:17:35 +10:00
committed by GitHub
parent db7847c34a
commit e5874f4565
22 changed files with 818 additions and 399 deletions

View File

@@ -14,6 +14,7 @@ detail:
Endpoint | Description |
| --- | -- |
[`/node`](./node.md) | General information about the beacon node.
[`/beacon`](./http_beacon.md) | General information about the beacon chain.
[`/validator`](./http_validator.md) | Provides functionality to validator clients.
[`/consensus`](./http_consensus.md) | Proof-of-stake voting statistics.

104
book/src/http_node.md Normal file
View File

@@ -0,0 +1,104 @@
# Lighthouse REST API: `/node`
The `/node` endpoints provide information about the lighthouse beacon node.
## Endpoints
HTTP Path | Description |
| --- | -- |
[`/node/version`](#nodeversion) | Get the node's version.
[`/node/syncing`](#nodesyncing) | Get the node's syncing status.
[`/node/syncing`](#nodelighthouse_syncing) | Get the node's syncing status
(Lighthouse specific).
## `/node/version`
Requests the beacon node's version.
### HTTP Specification
| Property | Specification |
| --- |--- |
Path | `/node/version`
Method | GET
JSON Encoding | String
Query Parameters | None
Typical Responses | 200
### Example Response
```json
"Lighthouse-0.2.0-unstable"
```
## `/node/syncing`
Requests the syncing status of the beacon node.
### HTTP Specification
| Property | Specification |
| --- |--- |
Path | `/node/syncing`
Method | GET
JSON Encoding | Object
Query Parameters | None
Typical Responses | 200
### Example Response
```json
{
is_syncing: true,
sync_status: {
starting_slot: 0,
current_slot: 100,
highest_slot: 200,
}
}
```
## `/node/lighthouse_syncing`
Requests the syncing state of a Lighthouse beacon node. Lighthouse as a
custom sync protocol, this request gets Lighthouse-specific sync information.
### HTTP Specification
| Property | Specification |
| --- |--- |
Path | `/node/lighthouse_syncing`
Method | GET
JSON Encoding | Object
Query Parameters | None
Typical Responses | 200
### Example Response
If the node is undergoing a finalization sync:
```json
{
"SyncingFinalized": {
"start_slot": 10,
"head_slot": 20,
"head_root":"0x74020d0e3c3c02d2ea6279d5760f7d0dd376c4924beaaec4d5c0cefd1c0c4465"
}
}
```
If the node is undergoing a head chain sync:
```json
{
"SyncingHead": {
"start_slot":0,
"head_slot":1195
}
}
```
If the node is synced
```json
{
"Synced"
}
```