mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-30 14:41:20 +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, ""),
|
"genesis": rpc.NewRPCFunc(GenesisResult, ""),
|
||||||
"block": rpc.NewRPCFunc(BlockResult, "height"),
|
"block": rpc.NewRPCFunc(BlockResult, "height"),
|
||||||
"commit": rpc.NewRPCFunc(CommitResult, "height"),
|
"commit": rpc.NewRPCFunc(CommitResult, "height"),
|
||||||
"tx": rpc.NewRPCFunc(TxResult, "hash"),
|
"tx": rpc.NewRPCFunc(TxResult, "hash,prove"),
|
||||||
"validators": rpc.NewRPCFunc(ValidatorsResult, ""),
|
"validators": rpc.NewRPCFunc(ValidatorsResult, ""),
|
||||||
"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusStateResult, ""),
|
"dump_consensus_state": rpc.NewRPCFunc(DumpConsensusStateResult, ""),
|
||||||
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""),
|
"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
|
// 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
|
// transaction is in the mempool, invalidated, or was not send in the first
|
||||||
// place.
|
// place.
|
||||||
func TxResult(hash []byte) (ctypes.TMResult, error) {
|
func TxResult(hash []byte, prove bool) (ctypes.TMResult, error) {
|
||||||
return Tx(hash)
|
return Tx(hash, prove)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BroadcastTxCommitResult(tx []byte) (ctypes.TMResult, error) {
|
func BroadcastTxCommitResult(tx []byte) (ctypes.TMResult, error) {
|
||||||
|
@ -4,9 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
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)
|
r, err := txIndexer.Tx(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -19,10 +20,16 @@ func Tx(hash []byte) (*ctypes.ResultTx, error) {
|
|||||||
block := blockStore.LoadBlock(int(r.Height))
|
block := blockStore.LoadBlock(int(r.Height))
|
||||||
tx := block.Data.Txs[int(r.Index)]
|
tx := block.Data.Txs[int(r.Index)]
|
||||||
|
|
||||||
|
var proof types.TxProof
|
||||||
|
if prove {
|
||||||
|
proof = block.Data.Txs.Proof(int(r.Index))
|
||||||
|
}
|
||||||
|
|
||||||
return &ctypes.ResultTx{
|
return &ctypes.ResultTx{
|
||||||
Height: r.Height,
|
Height: r.Height,
|
||||||
Index: r.Index,
|
Index: r.Index,
|
||||||
DeliverTx: r.DeliverTx,
|
DeliverTx: r.DeliverTx,
|
||||||
Tx: tx,
|
Tx: tx,
|
||||||
|
Proof: proof,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ type ResultTx struct {
|
|||||||
Index uint32 `json:"index"`
|
Index uint32 `json:"index"`
|
||||||
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
|
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
|
||||||
Tx types.Tx `json:"tx"`
|
Tx types.Tx `json:"tx"`
|
||||||
|
Proof types.TxProof `json:"proof,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResultUnconfirmedTxs struct {
|
type ResultUnconfirmedTxs struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user