Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok committed Jul 8, 2024
1 parent f5453e3 commit dbe8aa2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
57 changes: 27 additions & 30 deletions p2p/pkg/rpc/bidder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,42 +380,39 @@ func (s *Service) CancelAutoDeposit(
go func() {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
currentWindow, err := s.blockTrackerContract.GetCurrentWindow()
for range ticker.C {
currentWindow, err := s.blockTrackerContract.GetCurrentWindow()
if err != nil {
s.logger.Error("getting current window", "error", err)
continue
}
doWithdraw := true
for _, w := range windows {
if w.Uint64() >= currentWindow.Uint64() {
doWithdraw = false
break
}
}
if doWithdraw {
opts, err := s.optsGetter(ctx)
if err != nil {
s.logger.Error("getting current window", "error", err)
s.logger.Error("getting transact opts", "error", err)
continue
}
doWithdraw := true
for _, w := range windows {
if w.Uint64() >= currentWindow.Uint64() {
doWithdraw = false
break
}
txn, err := s.registryContract.WithdrawFromWindows(opts, windows)
if err != nil {
s.logger.Error("withdraw from windows", "error", err)
return
}
if doWithdraw {
opts, err := s.optsGetter(ctx)
if err != nil {
s.logger.Error("getting transact opts", "error", err)
continue
}
txn, err := s.registryContract.WithdrawFromWindows(opts, windows)
if err != nil {
s.logger.Error("withdraw from windows", "error", err)
return
}
receipt, err := s.watcher.WaitForReceipt(ctx, txn)
if err != nil {
s.logger.Error("waiting for receipt", "error", err)
return
}
if receipt.Status != types.ReceiptStatusSuccessful {
s.logger.Error("receipt status", "status", receipt.Status)
}
receipt, err := s.watcher.WaitForReceipt(ctx, txn)
if err != nil {
s.logger.Error("waiting for receipt", "error", err)
return
}
if receipt.Status != types.ReceiptStatusSuccessful {
s.logger.Error("receipt status", "status", receipt.Status)
}
return
}
}
}()
Expand Down
5 changes: 2 additions & 3 deletions p2p/pkg/rpc/bidder/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,8 @@ func TestAutoDepositHandling(t *testing.T) {
}

windows := make([]*wrapperspb.UInt64Value, 2)
for i, v := range resp.WindowNumbers {
windows[i] = v
}
copy(windows, resp.WindowNumbers)

_, err = client.WithdrawFromWindows(context.Background(), &bidderapiv1.WithdrawFromWindowsRequest{
WindowNumbers: windows,
})
Expand Down

0 comments on commit dbe8aa2

Please sign in to comment.