Skip to content

Commit

Permalink
Add event data to result event (#165)
Browse files Browse the repository at this point in the history
* add EventData to ResultEvent

* remove print

* deprecate legacy event data
  • Loading branch information
jewei1997 authored Nov 14, 2023
1 parent dd79101 commit 72bb29c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/rpc/core/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (env *Environment) Subscribe(ctx context.Context, req *coretypes.RequestSub
// We have a message to deliver to the client.
resp := callInfo.RPCRequest.MakeResponse(&coretypes.ResultEvent{
Query: req.Query,
Data: msg.LegacyData(),
Data: msg.Data(),
Events: msg.Events(),
})
wctx, cancel := context.WithTimeout(opctx, 10*time.Second)
Expand Down
2 changes: 1 addition & 1 deletion rpc/client/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (c *Local) eventsRoutine(ctx context.Context, sub eventbus.Subscription, su
case outc <- coretypes.ResultEvent{
SubscriptionID: msg.SubscriptionID(),
Query: qstr,
Data: msg.LegacyData(),
Data: msg.Data(),
Events: msg.Events(),
}:
case <-ctx.Done():
Expand Down
6 changes: 4 additions & 2 deletions rpc/client/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/base64"

"fmt"
"math"
"net/http"
Expand All @@ -21,6 +22,7 @@ import (
"github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/internal/mempool"
rpccore "github.com/tendermint/tendermint/internal/rpc/core"

tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmmath "github.com/tendermint/tendermint/libs/math"
Expand Down Expand Up @@ -495,9 +497,9 @@ func TestClientMethodCalls(t *testing.T) {
for i := int64(0); i < 3; i++ {
event := <-eventCh

blockEvent, ok := event.Data.(types.LegacyEventDataNewBlock)
blockEvent, ok := event.Data.(types.EventDataNewBlock)
if !ok {
blockEventPtr, okPtr := event.Data.(*types.LegacyEventDataNewBlock)
blockEventPtr, okPtr := event.Data.(*types.EventDataNewBlock)
if okPtr {
blockEvent = *blockEventPtr
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/coretypes/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ type (
type ResultEvent struct {
SubscriptionID string
Query string
Data types.LegacyEventData
Data types.EventData
Events []abci.Event
}

Expand Down

0 comments on commit 72bb29c

Please sign in to comment.