getBlockProduction
getBlockProduction
方法返回当前或前一个周期的区块生产信息。
请求参数
<object>
- (可选) 包含如下可选字段的配置对象:- (optional) Commitment
- (optional) range:
- firstSlot:
- first slot to return block production information for (inclusive) - (optional) lastSlot:
- last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot - (optional) identity:
- Only return results for this validator identity (base-58 encoded)
- (optional) lastSlot:
响应结果
getBlockProduction
方法返回一个RpcResponse JSON对象,可能的值为:
<object>
- byIdentity:
<object>
- 验证人标识字典,base-58编码。值为2元素数组,包含主导槽位数及生成的区块数 - range:
<object>
- 区块生产槽位范围 - firstSlot:
<u64>
- 区块生产信息的第一个槽位(包含) - lastSlot:
<u64>
- 区块生产信息的最后一个槽位(包含)
- byIdentity:
示例代码
请求:
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{"jsonrpc":"2.0","id":1, "method":"getBlockProduction"}
响应:
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 9887
},
"value": {
"byIdentity": {
"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [
9888,
9886
]
},
"range": {
"firstSlot": 0,
"lastSlot": 9887,
}
}
},
"id": 1
}
请求:
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction",
"params": [
{
"identity": "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr",
"range": {
"firstSlot": 40,
"lastSlot": 50
}
}
]
}
响应:
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 10102
},
"value": {
"byIdentity": {
"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [
11,
11
]
},
"range": {
"firstSlot": 50,
"lastSlot": 40
}
}
},
"id": 1
}