feat(events): add "Raw" suffix to {Get,Subscribe}ActorEvents
This is done with the intention to add new {Get,Subscribe}ActorEvents in a
future release (i.e. soon!) with both decoded values (dag-json represented)
and simplified (no flags or codec). But because this comes with some
trade-offs wrt fidelity of information (e.g. likely needing to drop events with
badly encoded values, and not retaining original codec), we need to also have
a Raw form of these APIs for consumers that want to take on the burden of
consuming them as they are.
This commit is contained in:
@@ -18,8 +18,8 @@ import (
|
||||
)
|
||||
|
||||
type ActorEventAPI interface {
|
||||
GetActorEvents(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error)
|
||||
SubscribeActorEvents(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error)
|
||||
GetActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error)
|
||||
SubscribeActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error)
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -89,7 +89,7 @@ func NewActorEventHandlerWithClock(
|
||||
}
|
||||
}
|
||||
|
||||
func (a *ActorEventHandler) GetActorEvents(ctx context.Context, evtFilter *types.ActorEventFilter) ([]*types.ActorEvent, error) {
|
||||
func (a *ActorEventHandler) GetActorEventsRaw(ctx context.Context, evtFilter *types.ActorEventFilter) ([]*types.ActorEvent, error) {
|
||||
if a.eventFilterManager == nil {
|
||||
return nil, api.ErrNotSupported
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func parseHeightRange(heaviest abi.ChainEpoch, fromHeight, toHeight *abi.ChainEp
|
||||
return minHeight, maxHeight, nil
|
||||
}
|
||||
|
||||
func (a *ActorEventHandler) SubscribeActorEvents(ctx context.Context, evtFilter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) {
|
||||
func (a *ActorEventHandler) SubscribeActorEventsRaw(ctx context.Context, evtFilter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) {
|
||||
if a.eventFilterManager == nil {
|
||||
return nil, api.ErrNotSupported
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestParseHeightRange(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetActorEvents(t *testing.T) {
|
||||
func TestGetActorEventsRaw(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
req := require.New(t)
|
||||
|
||||
@@ -231,7 +231,7 @@ func TestGetActorEvents(t *testing.T) {
|
||||
|
||||
handler := NewActorEventHandler(chain, efm, 50*time.Millisecond, maxFilterHeightRange)
|
||||
|
||||
gotEvents, err := handler.GetActorEvents(ctx, tc.filter)
|
||||
gotEvents, err := handler.GetActorEventsRaw(ctx, tc.filter)
|
||||
if tc.expectErr != "" {
|
||||
req.Error(err)
|
||||
req.Contains(err.Error(), tc.expectErr)
|
||||
@@ -245,7 +245,7 @@ func TestGetActorEvents(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubscribeActorEvents(t *testing.T) {
|
||||
func TestSubscribeActorEventsRaw(t *testing.T) {
|
||||
const (
|
||||
seed = 984651320
|
||||
maxFilterHeightRange = 100
|
||||
@@ -300,7 +300,7 @@ func TestSubscribeActorEvents(t *testing.T) {
|
||||
if tc.endEpoch >= 0 {
|
||||
aef.ToHeight = epochPtr(tc.endEpoch)
|
||||
}
|
||||
eventChan, err := handler.SubscribeActorEvents(ctx, aef)
|
||||
eventChan, err := handler.SubscribeActorEventsRaw(ctx, aef)
|
||||
req.NoError(err)
|
||||
|
||||
// assume we can cleanly pick up all historical events in one go
|
||||
@@ -411,8 +411,8 @@ func TestSubscribeActorEvents(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubscribeActorEvents_OnlyHistorical(t *testing.T) {
|
||||
// Similar to TestSubscribeActorEvents but we set an explicit end that caps out at the current height
|
||||
func TestSubscribeActorEventsRaw_OnlyHistorical(t *testing.T) {
|
||||
// Similar to TestSubscribeActorEventsRaw but we set an explicit end that caps out at the current height
|
||||
const (
|
||||
seed = 984651320
|
||||
maxFilterHeightRange = 100
|
||||
@@ -458,7 +458,7 @@ func TestSubscribeActorEvents_OnlyHistorical(t *testing.T) {
|
||||
handler := NewActorEventHandlerWithClock(mockChain, mockFilterManager, blockDelay, maxFilterHeightRange, mockClock)
|
||||
|
||||
aef := &types.ActorEventFilter{FromHeight: epochPtr(0), ToHeight: epochPtr(currentHeight)}
|
||||
eventChan, err := handler.SubscribeActorEvents(ctx, aef)
|
||||
eventChan, err := handler.SubscribeActorEventsRaw(ctx, aef)
|
||||
req.NoError(err)
|
||||
|
||||
var gotEvents []*types.ActorEvent
|
||||
|
||||
@@ -194,11 +194,11 @@ var ErrActorEventModuleDisabled = errors.New("module disabled, enable with Fevm.
|
||||
|
||||
type ActorEventDummy struct{}
|
||||
|
||||
func (a *ActorEventDummy) GetActorEvents(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error) {
|
||||
func (a *ActorEventDummy) GetActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error) {
|
||||
return nil, ErrActorEventModuleDisabled
|
||||
}
|
||||
|
||||
func (a *ActorEventDummy) SubscribeActorEvents(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) {
|
||||
func (a *ActorEventDummy) SubscribeActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error) {
|
||||
return nil, ErrActorEventModuleDisabled
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user