/tx returns tx bytes
This commit is contained in:
parent
7fbe8e47d4
commit
2a59cda77e
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
types/tx.go
10
types/tx.go
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue