rpc: add getSlotLeaders method (#16057)

This commit is contained in:
Justin Starry
2021-03-24 01:48:54 +08:00
committed by GitHub
parent 4f82b897bc
commit e7fd7d46cf
8 changed files with 239 additions and 28 deletions

View File

@ -52,6 +52,7 @@ gives a convenient interface for the RPC methods.
- [getSignatureStatuses](jsonrpc-api.md#getsignaturestatuses)
- [getSlot](jsonrpc-api.md#getslot)
- [getSlotLeader](jsonrpc-api.md#getslotleader)
- [getSlotLeaders](jsonrpc-api.md#getslotleaders)
- [getStakeActivation](jsonrpc-api.md#getstakeactivation)
- [getSupply](jsonrpc-api.md#getsupply)
- [getTokenAccountBalance](jsonrpc-api.md#gettokenaccountbalance)
@ -2252,6 +2253,53 @@ Result:
{"jsonrpc":"2.0","result":"ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS","id":1}
```
### getSlotLeaders
Returns the slot leaders for a given slot range
#### Parameters:
- `<u64>` - Start slot, as u64 integer
- `<u64>` - Limit, as u64 integer
#### Results:
- `<array<string>>` - Node identity public keys as base-58 encoded strings
#### Example:
If the current slot is #99, query the next 10 leaders with the following request:
Request:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{"jsonrpc":"2.0","id":1, "method":"getSlotLeaders", "params":[100, 10]}
'
```
Result:
The first leader returned is the leader for slot #100:
```json
{
"jsonrpc": "2.0",
"result": [
"ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n",
"ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n",
"ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n",
"ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n",
"Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM",
"Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM",
"Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM",
"Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM",
"DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP",
"DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP"
],
"id": 1
}
```
### getStakeActivation
Returns epoch activation information for a stake account