Skip to content

Commit c80ebad

Browse files
authored
fix: changed to not start from 0 (#166)
* fix: changed to not start from 0 * fix: increased timeout
1 parent 5bc56cb commit c80ebad

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

oracle/pkg/l1Listener/l1Listener.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ func (l *L1Listener) watchL1Block(ctx context.Context) error {
130130
ticker := time.NewTicker(checkInterval)
131131
defer ticker.Stop()
132132

133-
currentBlockNo := 0
133+
// TODO: change it to the store to not miss blocks, if oracle is down
134+
currentBlockNo, err := l.l1Client.BlockNumber(ctx)
135+
if err != nil {
136+
l.logger.Error("failed to get block number", "error", err)
137+
return err
138+
}
134139
for {
135140
select {
136141
case <-ctx.Done():
@@ -181,7 +186,7 @@ func (l *L1Listener) watchL1Block(ctx context.Context) error {
181186
)
182187
}
183188

184-
currentBlockNo = int(blockNum)
189+
currentBlockNo = blockNum
185190
}
186191
}
187192
}

oracle/pkg/l1Listener/l1Listener_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestL1Listener(t *testing.T) {
9393

9494
// ensure no winner is sent for the previous block
9595
select {
96-
case <-time.After(5 * time.Second):
96+
case <-time.After(10 * time.Second):
9797
t.Fatal("timeout waiting for winner")
9898
case update := <-rec.updates:
9999
if update.blockNum.Int64() != 11 {

0 commit comments

Comments
 (0)