Skip to content

Commit

Permalink
blockwatch: don't log backfilling statement when no blocks have elapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Apr 11, 2021
1 parent 3610c2e commit 55b14ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- \#1810 Display "n/a" in CLI when max gas price isn't specified (@kyriediculous)
- \#1827 Limit the maximum size of a segment read over HTTP (@jailuthra)
- \#1809 Don't log statement that blocks have been backfilled when no blocks have elapsed
- \#1809 Avoid nil pointer error in SyncToLatestBlock when no blocks are present in the database (@kyriediculous)

#### Orchestrator

Expand Down
6 changes: 5 additions & 1 deletion eth/blockwatch/block_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func (w *Watcher) syncToLatestBlock() error {
return err
}

if lastSeenHeader == nil {
return w.pollNextBlock()
}

for i := lastSeenHeader.Number; i.Cmp(newestHeader.Number) < 0; i = i.Add(i, big.NewInt(1)) {
if err := w.pollNextBlock(); err != nil {
return err
Expand Down Expand Up @@ -332,7 +336,7 @@ func (w *Watcher) getMissedEventsToBackfill(ctx context.Context) ([]*Event, erro
return events, nil
}

if blocksElapsed = latestBlockNum - startBlockNum; blocksElapsed == 0 {
if blocksElapsed = latestBlockNum - startBlockNum; blocksElapsed <= 0 {
return events, nil
}

Expand Down

0 comments on commit 55b14ac

Please sign in to comment.