mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-18 15:41:20 +00:00
/tx returns tx bytes
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -9,5 +11,18 @@ func Tx(hash []byte) (*ctypes.ResultTx, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
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 {
|
type ResultUnconfirmedTxs struct {
|
||||||
|
@ -242,11 +242,8 @@ func (s *State) ApplyBlock(eventCache types.Fireable, proxyAppConn proxy.AppConn
|
|||||||
|
|
||||||
batch := txindexer.NewBatch()
|
batch := txindexer.NewBatch()
|
||||||
for i, r := range txResults {
|
for i, r := range txResults {
|
||||||
if r != nil {
|
tx := block.Txs[i]
|
||||||
tx := block.Txs[i]
|
batch.Index(tx.Hash(), *r)
|
||||||
// dd2e325f79f7e5f77788759d278c1d4b370c842e => {"height":2405, "index":0, ...}
|
|
||||||
batch.Index(tx.Hash(), *r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
s.TxIndexer.Batch(batch)
|
s.TxIndexer.Batch(batch)
|
||||||
|
|
||||||
|
10
types/tx.go
10
types/tx.go
@ -1,6 +1,7 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/go-merkle"
|
"github.com/tendermint/go-merkle"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,3 +31,12 @@ func (txs Txs) Hash() []byte {
|
|||||||
return merkle.SimpleHashFromTwoHashes(left, right)
|
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"`
|
|
||||||
}
|
|
Reference in New Issue
Block a user