Browse Source

/tx returns tx bytes

pull/412/head
Ethan Buchman 7 years ago
parent
commit
2a59cda77e
5 changed files with 32 additions and 21 deletions
  1. +16
    -1
      rpc/core/tx.go
  2. +4
    -1
      rpc/core/types/responses.go
  3. +2
    -5
      state/execution.go
  4. +10
    -0
      types/tx.go
  5. +0
    -14
      types/tx_result.go

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

@ -1,6 +1,8 @@
package core
import (
"fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
@ -9,5 +11,18 @@ func Tx(hash []byte) (*ctypes.ResultTx, error) {
if err != nil {
return nil, err
}
return &ctypes.ResultTx{*r}, nil
if r == nil {
return &ctypes.ResultTx{}, fmt.Errorf("Tx (%X) not found", hash)
}
block := blockStore.LoadBlock(int(r.Height))
tx := block.Data.Txs[int(r.Index)]
return &ctypes.ResultTx{
Height: r.Height,
Index: r.Index,
DeliverTx: r.DeliverTx,
Tx: tx,
}, nil
}

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

@ -78,7 +78,10 @@ type ResultBroadcastTxCommit struct {
}
type ResultTx struct {
types.TxResult
Height uint64 `json:"height"`
Index uint32 `json:"index"`
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
Tx types.Tx `json:"tx"`
}
type ResultUnconfirmedTxs struct {


+ 2
- 5
state/execution.go View File

@ -242,11 +242,8 @@ func (s *State) ApplyBlock(eventCache types.Fireable, proxyAppConn proxy.AppConn
batch := txindexer.NewBatch()
for i, r := range txResults {
if r != nil {
tx := block.Txs[i]
// dd2e325f79f7e5f77788759d278c1d4b370c842e => {"height":2405, "index":0, ...}
batch.Index(tx.Hash(), *r)
}
tx := block.Txs[i]
batch.Index(tx.Hash(), *r)
}
s.TxIndexer.Batch(batch)


+ 10
- 0
types/tx.go View File

@ -1,6 +1,7 @@
package types
import (
abci "github.com/tendermint/abci/types"
"github.com/tendermint/go-merkle"
)
@ -30,3 +31,12 @@ func (txs Txs) Hash() []byte {
return merkle.SimpleHashFromTwoHashes(left, right)
}
}
// TxResult contains results of executing the transaction.
//
// One usage is indexing transaction results.
type TxResult struct {
Height uint64 `json:"height"`
Index uint32 `json:"index"`
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
}

+ 0
- 14
types/tx_result.go View File

@ -1,14 +0,0 @@
package types
import (
abci "github.com/tendermint/abci/types"
)
// TxResult contains results of executing the transaction.
//
// One usage is indexing transaction results.
type TxResult struct {
Height uint64 `json:"height"`
Index uint32 `json:"index"`
DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
}

Loading…
Cancel
Save