mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-28 02:44:16 +00:00
rewrite indexer to be a listener of eventBus
This commit is contained in:
@@ -100,7 +100,7 @@ func TestTxEventsSentWithBroadcastTxAsync(t *testing.T) {
|
||||
require.True(ok, "%d: %#v", i, evt)
|
||||
// make sure this is the proper tx
|
||||
require.EqualValues(tx, txe.Tx)
|
||||
require.True(txe.Code.IsOK())
|
||||
require.True(txe.Result.Code.IsOK())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,6 @@ func TestTxEventsSentWithBroadcastTxSync(t *testing.T) {
|
||||
require.True(ok, "%d: %#v", i, evt)
|
||||
// make sure this is the proper tx
|
||||
require.EqualValues(tx, txe.Tx)
|
||||
require.True(txe.Code.IsOK())
|
||||
require.True(txe.Result.Code.IsOK())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestABCIQuery(t *testing.T) {
|
||||
k, v, tx := MakeTxKV()
|
||||
bres, err := c.BroadcastTxCommit(tx)
|
||||
require.Nil(t, err, "%d: %+v", i, err)
|
||||
apph := bres.Height + 1 // this is where the tx will be applied to the state
|
||||
apph := int(bres.Height) + 1 // this is where the tx will be applied to the state
|
||||
|
||||
// wait before querying
|
||||
client.WaitForHeight(c, apph, nil)
|
||||
@@ -136,7 +136,7 @@ func TestAppCalls(t *testing.T) {
|
||||
bres, err := c.BroadcastTxCommit(tx)
|
||||
require.Nil(err, "%d: %+v", i, err)
|
||||
require.True(bres.DeliverTx.Code.IsOK())
|
||||
txh := bres.Height
|
||||
txh := int(bres.Height)
|
||||
apph := txh + 1 // this is where the tx will be applied to the state
|
||||
|
||||
// wait before querying
|
||||
@@ -153,7 +153,7 @@ func TestAppCalls(t *testing.T) {
|
||||
// ptx, err := c.Tx(bres.Hash, true)
|
||||
ptx, err := c.Tx(bres.Hash, true)
|
||||
require.Nil(err, "%d: %+v", i, err)
|
||||
assert.Equal(txh, ptx.Height)
|
||||
assert.EqualValues(txh, ptx.Height)
|
||||
assert.EqualValues(tx, ptx.Tx)
|
||||
|
||||
// and we can even check the block is added
|
||||
@@ -280,9 +280,9 @@ func TestTx(t *testing.T) {
|
||||
require.NotNil(err)
|
||||
} else {
|
||||
require.Nil(err, "%+v", err)
|
||||
assert.Equal(txHeight, ptx.Height)
|
||||
assert.EqualValues(txHeight, ptx.Height)
|
||||
assert.EqualValues(tx, ptx.Tx)
|
||||
assert.Equal(0, ptx.Index)
|
||||
assert.Zero(ptx.Index)
|
||||
assert.True(ptx.TxResult.Code.IsOK())
|
||||
|
||||
// time to verify the proof
|
||||
|
||||
+4
-4
@@ -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{
|
||||
|
||||
+4
-4
@@ -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