mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-20 06:06:15 +00:00
types: rename and extend the EventData interface (#7687)
This is the interface shared by types that can be used as event data in, for example, subscriptions via the RPC. To be compatible with the RPC service, data need to support JSON encoding. Require this as part of the interface.
This commit is contained in:
@@ -59,7 +59,7 @@ func WaitForHeight(ctx context.Context, c StatusClient, h int64, waiter Waiter)
|
||||
// when the timeout duration has expired.
|
||||
//
|
||||
// This handles subscribing and unsubscribing under the hood
|
||||
func WaitForOneEvent(c EventsClient, eventValue string, timeout time.Duration) (types.TMEventData, error) {
|
||||
func WaitForOneEvent(c EventsClient, eventValue string, timeout time.Duration) (types.EventData, error) {
|
||||
const subscriber = "helpers"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -3,7 +3,6 @@ package coretypes
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
@@ -307,7 +306,7 @@ type (
|
||||
type ResultEvent struct {
|
||||
SubscriptionID string
|
||||
Query string
|
||||
Data types.TMEventData
|
||||
Data types.EventData
|
||||
Events []abci.Event
|
||||
}
|
||||
|
||||
@@ -319,11 +318,7 @@ type resultEventJSON struct {
|
||||
}
|
||||
|
||||
func (r ResultEvent) MarshalJSON() ([]byte, error) {
|
||||
data, ok := r.Data.(jsontypes.Tagged)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type %T is not tagged", r.Data)
|
||||
}
|
||||
evt, err := jsontypes.Marshal(data)
|
||||
evt, err := jsontypes.Marshal(r.Data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user