mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 15:47:07 +00:00
consolidate saveResults/SaveABCIResponses
This commit is contained in:
+1
-1
@@ -149,7 +149,7 @@ type Header struct {
|
||||
LastCommitHash data.Bytes `json:"last_commit_hash"` // commit from validators from the last block
|
||||
DataHash data.Bytes `json:"data_hash"` // transactions
|
||||
|
||||
// hashes from the app
|
||||
// hashes from the app output from the prev block
|
||||
ValidatorsHash data.Bytes `json:"validators_hash"` // validators for the current block
|
||||
ConsensusHash data.Bytes `json:"consensus_hash"` // consensus params for current block
|
||||
AppHash data.Bytes `json:"app_hash"` // state after txs from the previous block
|
||||
|
||||
+10
-7
@@ -13,14 +13,13 @@ import (
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// ABCIResult is just the essential info to prove
|
||||
// success/failure of a DeliverTx
|
||||
// ABCIResult is the deterministic component of a ResponseDeliverTx.
|
||||
type ABCIResult struct {
|
||||
Code uint32 `json:"code"`
|
||||
Data data.Bytes `json:"data"`
|
||||
}
|
||||
|
||||
// Hash creates a canonical json hash of the ABCIResult
|
||||
// Hash returns the canonical json hash of the ABCIResult
|
||||
func (a ABCIResult) Hash() []byte {
|
||||
// stupid canonical json output, easy to check in any language
|
||||
bs := fmt.Sprintf(`{"code":%d,"data":"%s"}`, a.Code, a.Data)
|
||||
@@ -36,14 +35,18 @@ type ABCIResults []ABCIResult
|
||||
func NewResults(del []*abci.ResponseDeliverTx) ABCIResults {
|
||||
res := make(ABCIResults, len(del))
|
||||
for i, d := range del {
|
||||
res[i] = ABCIResult{
|
||||
Code: d.Code,
|
||||
Data: d.Data,
|
||||
}
|
||||
res[i] = NewResultFromResponse(d)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult {
|
||||
return ABCIResult{
|
||||
Code: response.Code,
|
||||
Data: response.Data,
|
||||
}
|
||||
}
|
||||
|
||||
// Bytes serializes the ABCIResponse using go-wire
|
||||
func (a ABCIResults) Bytes() []byte {
|
||||
return wire.BinaryBytes(a)
|
||||
|
||||
Reference in New Issue
Block a user