Skip to content

Commit 9c96148

Browse files
Merge pull request #94 from perun-network/93-simplify-eventsub
Merge EventSub.{ReadAll|ReadFuture} into Read
2 parents e16052e + 7317f9f commit 9c96148

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

backend/ethereum/channel/funder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (f *Funder) waitForFundingConfirmation(ctx context.Context, request channel
264264
defer sub.Close()
265265
// Read from the sub.
266266
go func() {
267-
subErr <- sub.ReadAll(ctx, deposited)
267+
subErr <- sub.Read(ctx, deposited)
268268
}()
269269

270270
// The allocation that all participants agreed on.

backend/ethereum/subscription/eventsub.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ func calcStartBlock(ctx context.Context, chain ethereum.ChainReader, pastBlocks
106106
return current.Number.Uint64() - pastBlocks, nil
107107
}
108108

109-
// ReadAll reads all past and future events into `sink`.
109+
// Read reads all past and future events into `sink`.
110110
// Can be aborted by cancelling `ctx` or `Close()`.
111111
// It is possible that the same event is read more than once.
112-
func (s *EventSub) ReadAll(ctx context.Context, sink chan<- *Event) error {
112+
func (s *EventSub) Read(ctx context.Context, sink chan<- *Event) error {
113113
// First read into the past.
114114
if err := s.readPast(ctx, sink); err != nil {
115115
return errors.WithMessage(err, "reading logs")
@@ -128,13 +128,6 @@ func (s *EventSub) ReadPast(ctx context.Context, sink chan<- *Event) error {
128128
return errors.WithMessage(s.readPast(ctx, sink), "reading logs")
129129
}
130130

131-
// ReadFuture reads all future events into `sink`.
132-
// Can be aborted by cancelling `ctx` or `Close()`.
133-
// It is possible that the same event is read more than once.
134-
func (s *EventSub) ReadFuture(ctx context.Context, sink chan<- *Event) error {
135-
return errors.WithMessage(s.readFuture(ctx, sink), "reading logs")
136-
}
137-
138131
func (s *EventSub) readPast(ctx context.Context, sink chan<- *Event) error {
139132
var logs []types.Log
140133
// Two read loops are needed if the event sub is closed before all events

backend/ethereum/subscription/eventsub_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestEventSub(t *testing.T) {
100100
require.NoError(t, err)
101101
go ct.Stage("sub", func(t pkgtest.ConcT) {
102102
defer close(sink)
103-
require.NoError(t, sub.ReadAll(context.Background(), sink))
103+
require.NoError(t, sub.Read(context.Background(), sink))
104104
})
105105

106106
go ct.Stage("receiver", func(t pkgtest.ConcT) {
@@ -181,7 +181,7 @@ func TestEventSub_Filter(t *testing.T) {
181181
require.NoError(t, err)
182182
go ct.Stage("sub", func(t pkgtest.ConcT) {
183183
defer close(sink)
184-
require.NoError(t, sub.ReadAll(context.Background(), sink))
184+
require.NoError(t, sub.Read(context.Background(), sink))
185185
})
186186

187187
// Receive 1 event.

0 commit comments

Comments
 (0)