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 17:07:03 +07:00
committed by GitHub
parent 0a159c2613
commit 843d63f935
14 changed files with 757 additions and 279 deletions

View File

@@ -76,10 +76,11 @@ func (app *KVStoreApplication) DeliverTx(req types.RequestDeliverTx) types.Resul
events := []abci.Event{
{
Type: "transfer",
Attributes: kv.Pairs{
kv.Pair{Key: []byte("sender"), Value: []byte("Bob")},
kv.Pair{Key: []byte("recipient"), Value: []byte("Alice")},
kv.Pair{Key: []byte("balance"), Value: []byte("100")},
Attributes: []abci.EventAttribute{
{Key: []byte("sender"), Value: []byte("Bob")},
{Key: []byte("recipient"), Value: []byte("Alice")},
{Key: []byte("balance"), Value: []byte("100")},
{Key: []byte("note"), Value: []byte("nothing"), Index: true},
},
},
}
@@ -98,6 +99,9 @@ Note, there are a few predefined event types:
Tendermint will throw a warning if you try to use any of the above keys.
The index will be added if the `Index` field of attribute is set to true. In above example, querying
using `transfer.note` will work.
## Querying Transactions
You can query the transaction results by calling `/tx_search` RPC endpoint: