docs: update /block_results RPC docs (#3708)

Fixes #3616
This commit is contained in:
Anton Kaliaev
2019-06-05 10:36:16 +09:00
committed by GitHub
parent c69ec87f67
commit 2a23eca368
3 changed files with 27 additions and 15 deletions

View File

@ -5,6 +5,8 @@
### BREAKING CHANGES: ### BREAKING CHANGES:
* CLI/RPC/Config * CLI/RPC/Config
- [rpc] \#3616 Improve `/block_results` response format (`results.DeliverTx` ->
`results.deliver_tx`). See docs for details.
* Apps * Apps

View File

@ -339,7 +339,8 @@ func Commit(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCommit, erro
// If no height is provided, it will fetch results for the latest block. // If no height is provided, it will fetch results for the latest block.
// //
// Results are for the height of the block containing the txs. // Results are for the height of the block containing the txs.
// Thus response.results[5] is the results of executing getBlock(h).Txs[5] // Thus response.results.deliver_tx[5] is the results of executing
// getBlock(h).Txs[5]
// //
// ```shell // ```shell
// curl 'localhost:26657/block_results?height=10' // curl 'localhost:26657/block_results?height=10'
@ -360,17 +361,27 @@ func Commit(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCommit, erro
// //
// ```json // ```json
// { // {
// "height": "10", // "jsonrpc": "2.0",
// "results": [ // "id": "",
// { // "result": {
// "code": "0", // "height": "39",
// "data": "CAFE00F00D" // "results": {
// }, // "deliver_tx": [
// { // {
// "code": "102", // "tags": [
// "data": "" // {
// "key": "YXBwLmNyZWF0b3I=",
// "value": "Q29zbW9zaGkgTmV0b3dva28="
// }
// ]
// }
// ],
// "end_block": {
// "validator_updates": null
// },
// "begin_block": {}
// }
// } // }
// ]
// } // }
// ``` // ```
func BlockResults(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockResults, error) { func BlockResults(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockResults, error) {
@ -380,7 +391,6 @@ func BlockResults(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockR
return nil, err return nil, err
} }
// load the results
results, err := sm.LoadABCIResponses(stateDB, height) results, err := sm.LoadABCIResponses(stateDB, height)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -115,9 +115,9 @@ func saveState(db dbm.DB, state State, key []byte) {
// of the various ABCI calls during block processing. // of the various ABCI calls during block processing.
// It is persisted to disk for each height before calling Commit. // It is persisted to disk for each height before calling Commit.
type ABCIResponses struct { type ABCIResponses struct {
DeliverTx []*abci.ResponseDeliverTx DeliverTx []*abci.ResponseDeliverTx `json:"deliver_tx"`
EndBlock *abci.ResponseEndBlock EndBlock *abci.ResponseEndBlock `json:"end_block"`
BeginBlock *abci.ResponseBeginBlock BeginBlock *abci.ResponseBeginBlock `json:"begin_block"`
} }
// NewABCIResponses returns a new ABCIResponses // NewABCIResponses returns a new ABCIResponses