Skip to content

Commit

Permalink
eth: timewatcher code cleanup, remove fetchAndSetTranscoderPoolSize
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Apr 12, 2021
1 parent aeeab38 commit 4e3ab38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions eth/watchers/timewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewTimeWatcher(roundsManagerAddr ethcommon.Address, watcher BlockWatcher, l
}
num, err := tw.lpEth.CurrentRoundStartBlock()
if err != nil {
return nil, fmt.Errorf("error fetching current round start block %v=", err)
return nil, fmt.Errorf("error fetching current round start block err=%v", err)
}
tw.setLastInitializedRound(lr, bh, num)

Expand All @@ -85,9 +85,11 @@ func NewTimeWatcher(roundsManagerAddr ethcommon.Address, watcher BlockWatcher, l
}
tw.setLastSeenBlock(blockNum)

if err := tw.fetchAndSetTranscoderPoolSize(); err != nil {
size, err := tw.lpEth.GetTranscoderPoolSize()
if err != nil {
return nil, fmt.Errorf("error fetching initial transcoderPoolSize err=%v", err)
}
tw.setTranscoderPoolSize(size)

return tw, nil
}
Expand Down Expand Up @@ -245,20 +247,13 @@ func (tw *TimeWatcher) handleLog(log types.Log) error {
}

// Get the active transcoder pool size when we receive a NewRound event
if err := tw.fetchAndSetTranscoderPoolSize(); err != nil {
return err
}

tw.roundSubFeed.Send(log)

return nil
}

func (tw *TimeWatcher) fetchAndSetTranscoderPoolSize() error {
size, err := tw.lpEth.GetTranscoderPoolSize()
if err != nil {
return err
}
tw.setTranscoderPoolSize(size)

tw.roundSubFeed.Send(log)

return nil
}
2 changes: 1 addition & 1 deletion eth/watchers/timewatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestTimeWatcher_NewTimeWatcher(t *testing.T) {

// CurrentRoundStartBlock error
lpEth.Errors["CurrentRoundStartBlock"] = testErr
expErr = fmt.Sprintf("error fetching current round start block %v=", testErr)
expErr = fmt.Sprintf("error fetching current round start block err=%v", testErr)
tw, err = NewTimeWatcher(stubRoundsManagerAddr, watcher, lpEth)
assert.Nil(tw)
assert.EqualError(err, expErr)
Expand Down

0 comments on commit 4e3ab38

Please sign in to comment.