Skip to content

Commit 06c7864

Browse files
committed
Use subscription with forced inclusion; refactorings
1 parent 31b52b3 commit 06c7864

22 files changed

Lines changed: 954 additions & 934 deletions

block/internal/common/event.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package common
22

3-
import "github.com/evstack/ev-node/types"
3+
import (
4+
"context"
5+
6+
"github.com/evstack/ev-node/types"
7+
)
48

59
// EventSource represents the origin of a block event
610
type EventSource string
@@ -24,3 +28,18 @@ type DAHeightEvent struct {
2428
// Optional DA height hints from P2P. first is the DA height hint for the header, second is the DA height hint for the data
2529
DaHeightHints [2]uint64
2630
}
31+
32+
// EventSink receives parsed DA events with backpressure support.
33+
type EventSink interface {
34+
PipeEvent(ctx context.Context, event DAHeightEvent) error
35+
}
36+
37+
// EventSinkFunc adapts a plain function to the EventSink interface.
38+
// Useful in tests:
39+
//
40+
// sink := common.EventSinkFunc(func(ctx context.Context, ev common.DAHeightEvent) error { return nil })
41+
type EventSinkFunc func(ctx context.Context, event DAHeightEvent) error
42+
43+
func (f EventSinkFunc) PipeEvent(ctx context.Context, event DAHeightEvent) error {
44+
return f(ctx, event)
45+
}

0 commit comments

Comments
 (0)