From 2a23eca36845b11f6f1755528750889a3ffcacb7 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 5 Jun 2019 10:36:16 +0900 Subject: [PATCH] docs: update /block_results RPC docs (#3708) Fixes #3616 --- CHANGELOG_PENDING.md | 2 ++ rpc/core/blocks.go | 34 ++++++++++++++++++++++------------ state/store.go | 6 +++--- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index c22cb9daf..f37904d1b 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -5,6 +5,8 @@ ### BREAKING CHANGES: * CLI/RPC/Config +- [rpc] \#3616 Improve `/block_results` response format (`results.DeliverTx` -> + `results.deliver_tx`). See docs for details. * Apps diff --git a/rpc/core/blocks.go b/rpc/core/blocks.go index 40b6811db..16ebe9c56 100644 --- a/rpc/core/blocks.go +++ b/rpc/core/blocks.go @@ -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. // // 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 // curl 'localhost:26657/block_results?height=10' @@ -360,17 +361,27 @@ func Commit(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultCommit, erro // // ```json // { -// "height": "10", -// "results": [ -// { -// "code": "0", -// "data": "CAFE00F00D" -// }, -// { -// "code": "102", -// "data": "" +// "jsonrpc": "2.0", +// "id": "", +// "result": { +// "height": "39", +// "results": { +// "deliver_tx": [ +// { +// "tags": [ +// { +// "key": "YXBwLmNyZWF0b3I=", +// "value": "Q29zbW9zaGkgTmV0b3dva28=" +// } +// ] +// } +// ], +// "end_block": { +// "validator_updates": null +// }, +// "begin_block": {} +// } // } -// ] // } // ``` 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 } - // load the results results, err := sm.LoadABCIResponses(stateDB, height) if err != nil { return nil, err diff --git a/state/store.go b/state/store.go index 0301bc7c3..f0bb9e142 100644 --- a/state/store.go +++ b/state/store.go @@ -115,9 +115,9 @@ func saveState(db dbm.DB, state State, key []byte) { // of the various ABCI calls during block processing. // It is persisted to disk for each height before calling Commit. type ABCIResponses struct { - DeliverTx []*abci.ResponseDeliverTx - EndBlock *abci.ResponseEndBlock - BeginBlock *abci.ResponseBeginBlock + DeliverTx []*abci.ResponseDeliverTx `json:"deliver_tx"` + EndBlock *abci.ResponseEndBlock `json:"end_block"` + BeginBlock *abci.ResponseBeginBlock `json:"begin_block"` } // NewABCIResponses returns a new ABCIResponses