mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 04:01:55 +00:00
rewrite indexer to be a listener of eventBus
This commit is contained in:
@@ -154,7 +154,7 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), subscribeTimeout)
|
||||
defer cancel()
|
||||
deliverTxResCh := make(chan interface{})
|
||||
q := types.EventQueryTx(tx)
|
||||
q := types.EventQueryTxFor(tx)
|
||||
err := eventBus.Subscribe(ctx, "mempool", q, deliverTxResCh)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "failed to subscribe to tx")
|
||||
@@ -192,9 +192,9 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
deliverTxRes := deliverTxResMsg.(types.TMEventData).Unwrap().(types.EventDataTx)
|
||||
// The tx was included in a block.
|
||||
deliverTxR := &abci.ResponseDeliverTx{
|
||||
Code: deliverTxRes.Code,
|
||||
Data: deliverTxRes.Data,
|
||||
Log: deliverTxRes.Log,
|
||||
Code: deliverTxRes.Result.Code,
|
||||
Data: deliverTxRes.Result.Data,
|
||||
Log: deliverTxRes.Result.Log,
|
||||
}
|
||||
logger.Info("DeliverTx passed ", "tx", data.Bytes(tx), "response", deliverTxR)
|
||||
return &ctypes.ResultBroadcastTxCommit{
|
||||
|
@@ -82,13 +82,13 @@ func Tx(hash []byte, prove bool) (*ctypes.ResultTx, error) {
|
||||
return nil, fmt.Errorf("Tx (%X) not found", hash)
|
||||
}
|
||||
|
||||
height := int(r.Height) // XXX
|
||||
index := int(r.Index)
|
||||
height := r.Height
|
||||
index := r.Index
|
||||
|
||||
var proof types.TxProof
|
||||
if prove {
|
||||
block := blockStore.LoadBlock(height)
|
||||
proof = block.Data.Txs.Proof(index)
|
||||
block := blockStore.LoadBlock(int(height))
|
||||
proof = block.Data.Txs.Proof(int(index))
|
||||
}
|
||||
|
||||
return &ctypes.ResultTx{
|
||||
|
@@ -107,12 +107,12 @@ type ResultBroadcastTxCommit struct {
|
||||
CheckTx abci.Result `json:"check_tx"`
|
||||
DeliverTx abci.Result `json:"deliver_tx"`
|
||||
Hash data.Bytes `json:"hash"`
|
||||
Height int `json:"height"`
|
||||
Height uint64 `json:"height"`
|
||||
}
|
||||
|
||||
type ResultTx struct {
|
||||
Height int `json:"height"`
|
||||
Index int `json:"index"`
|
||||
Height uint64 `json:"height"`
|
||||
Index uint32 `json:"index"`
|
||||
TxResult abci.Result `json:"tx_result"`
|
||||
Tx types.Tx `json:"tx"`
|
||||
Proof types.TxProof `json:"proof,omitempty"`
|
||||
|
Reference in New Issue
Block a user