Rpc: introduce get_inflation_reward rpc call (#16278)
* feat: introduce get_inflation_reward rpc call * fix: style suggestions * fix: more style changes and match how other rpc functions are defined * feat: get reward for a single epoch * feat: default to the most recent epoch * fix: don't factor out get_confirmed_block * style: introduce from impl for RpcEncodingConfigWrapper * style: bring commitment into variable * feat: support multiple pubkeys for get_inflation_reward * feat: add get_inflation_reward to rpc client * feat: return rewards in order * fix: rename pubkeys to addresses * docs: introduce jsonrpc docs for get_inflation_reward * style: early return in map (not sure which is more idiomatic) * fix: call the rpc client function args addresses as well * fix: style * fix: filter out only addresses we care about * style: make this more idiomatic * fix: change rpc client epoch to optional and include some docs edits * feat: filter out rent rewards in get_inflation_reward * feat: add option epoch config param to get_inflation_reward * feat: rpc client get_inflation_reward takes epoch instead of config and some filter staking and voting rewards
This commit is contained in:
@ -40,6 +40,7 @@ gives a convenient interface for the RPC methods.
|
||||
- [getIdentity](jsonrpc-api.md#getidentity)
|
||||
- [getInflationGovernor](jsonrpc-api.md#getinflationgovernor)
|
||||
- [getInflationRate](jsonrpc-api.md#getinflationrate)
|
||||
- [getInflationReward](jsonrpc-api.md#getinflationreward)
|
||||
- [getLargestAccounts](jsonrpc-api.md#getlargestaccounts)
|
||||
- [getLeaderSchedule](jsonrpc-api.md#getleaderschedule)
|
||||
- [getMaxRetransmitSlot](jsonrpc-api.md#getmaxretransmitslot)
|
||||
@ -1468,6 +1469,58 @@ Result:
|
||||
{"jsonrpc":"2.0","result":{"epoch":100,"foundation":0.001,"total":0.149,"validator":0.148},"id":1}
|
||||
```
|
||||
|
||||
### getInflationReward
|
||||
|
||||
Returns the inflation reward for a list of addresses for an epoch
|
||||
|
||||
#### Parameters:
|
||||
- `<array>` - An array of addresses to query, as base-58 encoded strings
|
||||
* `<object>` - (optional) Configuration object containing the following optional fields:
|
||||
* (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||
* (optional) `epoch: <u64>` - An epoch for which the reward occurs. If omitted, the previous epoch will be used
|
||||
|
||||
#### Results
|
||||
|
||||
The result field will be a JSON array with the following fields:
|
||||
|
||||
- `epoch: <u64>`, epoch
|
||||
- `effective_slot: <u64>`, the slot in which the rewards are effective
|
||||
- `amount: <u64>`, reward amount in lamports
|
||||
- `post_balance: <u64>`, post balance of the account in lamports
|
||||
|
||||
#### Example
|
||||
|
||||
Request:
|
||||
```bash
|
||||
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "getInflationReward",
|
||||
"params": [
|
||||
["6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu", "BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2"], 2
|
||||
]
|
||||
}
|
||||
'
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"result": [
|
||||
{
|
||||
"amount": 2500,
|
||||
"effectiveSlot": 224,
|
||||
"epoch": 2,
|
||||
"postBalance": 499999442500
|
||||
},
|
||||
null
|
||||
],
|
||||
"id": 1
|
||||
}
|
||||
```
|
||||
|
||||
### getLargestAccounts
|
||||
|
||||
Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours)
|
||||
|
Reference in New Issue
Block a user