mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-28 21:51:22 +00:00
add optional 'prove' flag to /tx
This commit is contained in:
parent
7fb0e8b30b
commit
6899c91ebe
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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…
x
Reference in New Issue
Block a user