backport: implement the ADR 075 /events method (#7965) (#9497)

* rpc: implement the ADR 075 /events method (#7965)

This method implements the eventlog extension interface to expose ABCI metadata
to the log for query processing. Only the types that have ABCI events need to
implement this.

- Add an event log to the environment
- Add a sketch of the handler method
- Add an /events RPCFunc to the route map
- Implement query logic
- Subscribe to pubsub if confingured, handle termination

* add MatchesEvents test

* add TODO due to backport sequence

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
This commit is contained in:
mmsqe
2022-10-04 22:52:27 +02:00
committed by GitHub
co-authored by M. J. Fromberger
parent 069e402aa1
commit d47b675cda
10 changed files with 315 additions and 1 deletions
+7
View File
@@ -95,6 +95,13 @@ func (q *Query) Matches(events map[string][]string) (bool, error) {
return q.matchesEvents(ExpandEvents(events)), nil
}
func (q *Query) MatchesEvents(events []types.Event) (bool, error) {
if q == nil {
return true, nil
}
return q.matchesEvents(events), nil
}
// String matches part of the pubsub.Query interface.
func (q *Query) String() string {
if q == nil {
+10
View File
@@ -332,6 +332,16 @@ func TestCompiledMatches(t *testing.T) {
t.Errorf("Query: %#q\nInput: %+v\nMatches: got %v, want %v",
tc.s, tc.events, got, tc.matches)
}
got, err = c.MatchesEvents(query.ExpandEvents(tc.events))
if err != nil {
t.Errorf("Query: %#q\nInput: %+v\nMatches: got error %v",
tc.s, tc.events, err)
}
if got != tc.matches {
t.Errorf("Query: %#q\nInput: %+v\nMatches: got %v, want %v",
tc.s, tc.events, got, tc.matches)
}
})
}
}