indexer: allow indexing an event at runtime (#4466)

The PR added a new field `index` to event attribute, that will cause indexer service to index the event if set to true.
This commit is contained in:
Diep Pham
2020-04-22 12:07:03 +02:00
committed by GitHub
parent 0a159c2613
commit 843d63f935
14 changed files with 757 additions and 279 deletions
+8 -9
View File
@@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/kv"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
tmrand "github.com/tendermint/tendermint/libs/rand"
@@ -27,7 +26,7 @@ func TestEventBusPublishEventTx(t *testing.T) {
result := abci.ResponseDeliverTx{
Data: []byte("bar"),
Events: []abci.Event{
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("baz"), Value: []byte("1")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
},
}
@@ -71,12 +70,12 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
resultBeginBlock := abci.ResponseBeginBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("baz"), Value: []byte("1")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
},
}
resultEndBlock := abci.ResponseEndBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("foz"), Value: []byte("2")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("foz"), Value: []byte("2")}}},
},
}
@@ -121,7 +120,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
Events: []abci.Event{
{
Type: "transfer",
Attributes: []kv.Pair{
Attributes: []abci.EventAttribute{
{Key: []byte("sender"), Value: []byte("foo")},
{Key: []byte("recipient"), Value: []byte("bar")},
{Key: []byte("amount"), Value: []byte("5")},
@@ -129,7 +128,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
},
{
Type: "transfer",
Attributes: []kv.Pair{
Attributes: []abci.EventAttribute{
{Key: []byte("sender"), Value: []byte("baz")},
{Key: []byte("recipient"), Value: []byte("cat")},
{Key: []byte("amount"), Value: []byte("13")},
@@ -137,7 +136,7 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
},
{
Type: "withdraw.rewards",
Attributes: []kv.Pair{
Attributes: []abci.EventAttribute{
{Key: []byte("address"), Value: []byte("bar")},
{Key: []byte("source"), Value: []byte("iceman")},
{Key: []byte("amount"), Value: []byte("33")},
@@ -218,12 +217,12 @@ func TestEventBusPublishEventNewBlockHeader(t *testing.T) {
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
resultBeginBlock := abci.ResponseBeginBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("baz"), Value: []byte("1")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("baz"), Value: []byte("1")}}},
},
}
resultEndBlock := abci.ResponseEndBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []kv.Pair{{Key: []byte("foz"), Value: []byte("2")}}},
{Type: "testType", Attributes: []abci.EventAttribute{{Key: []byte("foz"), Value: []byte("2")}}},
},
}