Browse Source

rpc: response types use Result instead of pb Response

pull/467/head
Ethan Buchman 8 years ago
parent
commit
a518d08839
5 changed files with 47 additions and 19 deletions
  1. +9
    -1
      rpc/core/abci.go
  2. +6
    -6
      rpc/core/mempool.go
  3. +1
    -1
      rpc/core/tx.go
  4. +16
    -10
      rpc/core/types/responses.go
  5. +15
    -1
      rpc/grpc/api.go

+ 9
- 1
rpc/core/abci.go View File

@ -18,7 +18,15 @@ func ABCIQuery(path string, data data.Bytes, prove bool) (*ctypes.ResultABCIQuer
return nil, err
}
log.Info("ABCIQuery", "path", path, "data", data, "result", resQuery)
return &ctypes.ResultABCIQuery{resQuery}, nil
return &ctypes.ResultABCIQuery{
Code: resQuery.Code,
Index: resQuery.Index,
Key: resQuery.Key,
Value: resQuery.Value,
Proof: resQuery.Proof,
Height: resQuery.Height,
Log: resQuery.Log,
}, nil
}
func ABCIInfo() (*ctypes.ResultABCIInfo, error) {


+ 6
- 6
rpc/core/mempool.go View File

@ -67,8 +67,8 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
if checkTxR.Code != abci.CodeType_OK {
// CheckTx failed!
return &ctypes.ResultBroadcastTxCommit{
CheckTx: checkTxR,
DeliverTx: nil,
CheckTx: checkTxR.Result(),
DeliverTx: abci.Result{},
Hash: tx.Hash(),
}, nil
}
@ -87,16 +87,16 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
}
log.Notice("DeliverTx passed ", "tx", data.Bytes(tx), "response", deliverTxR)
return &ctypes.ResultBroadcastTxCommit{
CheckTx: checkTxR,
DeliverTx: deliverTxR,
CheckTx: checkTxR.Result(),
DeliverTx: deliverTxR.Result(),
Hash: tx.Hash(),
Height: deliverTxRes.Height,
}, nil
case <-timer.C:
log.Error("failed to include tx")
return &ctypes.ResultBroadcastTxCommit{
CheckTx: checkTxR,
DeliverTx: nil,
CheckTx: checkTxR.Result(),
DeliverTx: abci.Result{},
Hash: tx.Hash(),
}, fmt.Errorf("Timed out waiting for transaction to be included in a block")
}


+ 1
- 1
rpc/core/tx.go View File

@ -36,7 +36,7 @@ func Tx(hash []byte, prove bool) (*ctypes.ResultTx, error) {
return &ctypes.ResultTx{
Height: height,
Index: index,
TxResult: r.Result,
TxResult: r.Result.Result(),
Tx: r.Tx,
Proof: proof,
}, nil


+ 16
- 10
rpc/core/types/responses.go View File

@ -89,18 +89,18 @@ type ResultBroadcastTx struct {
}
type ResultBroadcastTxCommit struct {
CheckTx *abci.ResponseCheckTx `json:"check_tx"`
DeliverTx *abci.ResponseDeliverTx `json:"deliver_tx"`
Hash data.Bytes `json:"hash"`
Height int `json:"height"`
CheckTx abci.Result `json:"check_tx"`
DeliverTx abci.Result `json:"deliver_tx"`
Hash data.Bytes `json:"hash"`
Height int `json:"height"`
}
type ResultTx struct {
Height int `json:"height"`
Index int `json:"index"`
TxResult abci.ResponseDeliverTx `json:"tx_result"`
Tx types.Tx `json:"tx"`
Proof types.TxProof `json:"proof,omitempty"`
Height int `json:"height"`
Index int `json:"index"`
TxResult abci.Result `json:"tx_result"`
Tx types.Tx `json:"tx"`
Proof types.TxProof `json:"proof,omitempty"`
}
type ResultUnconfirmedTxs struct {
@ -113,7 +113,13 @@ type ResultABCIInfo struct {
}
type ResultABCIQuery struct {
Response abci.ResponseQuery `json:"response"`
Code abci.CodeType `json:"code"`
Index int64 `json:"index"`
Key []byte `json:"key"`
Value []byte `json:"value"`
Proof []byte `json:"proof"`
Height uint64 `json:"height"`
Log string `json:"log"`
}
type ResultUnsafeFlushMempool struct{}


+ 15
- 1
rpc/grpc/api.go View File

@ -3,6 +3,8 @@ package core_grpc
import (
core "github.com/tendermint/tendermint/rpc/core"
abci "github.com/tendermint/abci/types"
context "golang.org/x/net/context"
)
@ -14,5 +16,17 @@ func (bapi *broadcastAPI) BroadcastTx(ctx context.Context, req *RequestBroadcast
if err != nil {
return nil, err
}
return &ResponseBroadcastTx{res.CheckTx, res.DeliverTx}, nil
return &ResponseBroadcastTx{
CheckTx: &abci.ResponseCheckTx{
Code: res.CheckTx.Code,
Data: res.CheckTx.Data,
Log: res.CheckTx.Log,
},
DeliverTx: &abci.ResponseDeliverTx{
Code: res.DeliverTx.Code,
Data: res.DeliverTx.Data,
Log: res.DeliverTx.Log,
},
}, nil
}

Loading…
Cancel
Save