Browse Source

add optional 'prove' flag to /tx

pull/412/head
Ethan Buchman 7 years ago
parent
commit
6899c91ebe
3 changed files with 12 additions and 4 deletions
  1. +3
    -3
      rpc/core/routes.go
  2. +8
    -1
      rpc/core/tx.go
  3. +1
    -0
      rpc/core/types/responses.go

+ 3
- 3
rpc/core/routes.go View File

@ -19,7 +19,7 @@ var Routes = map[string]*rpc.RPCFunc{
"genesis": rpc.NewRPCFunc(GenesisResult, ""),
"block": rpc.NewRPCFunc(BlockResult, "height"),
"commit": rpc.NewRPCFunc(CommitResult, "height"),
"tx": rpc.NewRPCFunc(TxResult, "hash"),
"tx": rpc.NewRPCFunc(TxResult, "hash,prove"),
"validators": rpc.NewRPCFunc(ValidatorsResult, ""),
"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusStateResult, ""),
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""),
@ -100,8 +100,8 @@ func NumUnconfirmedTxsResult() (ctypes.TMResult, error) {
// Tx allow user to query the transaction results. `nil` could mean the
// transaction is in the mempool, invalidated, or was not send in the first
// place.
func TxResult(hash []byte) (ctypes.TMResult, error) {
return Tx(hash)
func TxResult(hash []byte, prove bool) (ctypes.TMResult, error) {
return Tx(hash, prove)
}
func BroadcastTxCommitResult(tx []byte) (ctypes.TMResult, error) {


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

@ -4,9 +4,10 @@ import (
"fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
)
func Tx(hash []byte) (*ctypes.ResultTx, error) {
func Tx(hash []byte, prove bool) (*ctypes.ResultTx, error) {
r, err := txIndexer.Tx(hash)
if err != nil {
return nil, err
@ -19,10 +20,16 @@ func Tx(hash []byte) (*ctypes.ResultTx, error) {
block := blockStore.LoadBlock(int(r.Height))
tx := block.Data.Txs[int(r.Index)]
var proof types.TxProof
if prove {
proof = block.Data.Txs.Proof(int(r.Index))
}
return &ctypes.ResultTx{
Height: r.Height,
Index: r.Index,
DeliverTx: r.DeliverTx,
Tx: tx,
Proof: proof,
}, nil
}

+ 1
- 0
rpc/core/types/responses.go View File

@ -83,6 +83,7 @@ type ResultTx struct {
Index uint32 `json:"index"`
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
Tx types.Tx `json:"tx"`
Proof types.TxProof `json:"proof,omitempty"`
}
type ResultUnconfirmedTxs struct {


Loading…
Cancel
Save