Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jul 11, 2024
1 parent d404dba commit 1a23d42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions node/impl/full/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (f3api *F3API) F3Participate(ctx context.Context, miner address.Address,
newLeaseExpiration time.Time, oldLeaseExpiration time.Time) (bool, error) {

if leaseDuration := time.Until(newLeaseExpiration); leaseDuration > 5*time.Minute {
return false, xerrors.Errorf("F3 participation lease too long: %v > 15 min", leaseDuration)
return false, xerrors.Errorf("F3 participation lease too long: %v > 5 min", leaseDuration)
} else if leaseDuration < 0 {
return false, xerrors.Errorf("F3 participation lease is in the past: %d < 0", leaseDuration)
}
Expand All @@ -39,7 +39,7 @@ func (f3api *F3API) F3Participate(ctx context.Context, miner address.Address,
}
minerID, err := address.IDFromAddress(miner)
if err != nil {
return false, xerrors.Errorf("miner address is not of ID type: %v: %+v", miner, err)
return false, xerrors.Errorf("miner address is not of ID type: %v: %w", miner, err)
}

return f3api.F3.Participate(ctx, minerID, newLeaseExpiration, oldLeaseExpiration), nil
Expand Down
6 changes: 3 additions & 3 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func F3Participation(mctx helpers.MetricsCtx, lc fx.Lifecycle, api v1api.FullNod

ok, err := api.F3Participate(ctx, address.Address(minerAddress), newLease, oldLease)

if errors.Is(err, context.Canceled) {
if ctx.Err() != nil {
return
}
if errors.Is(err, full.ErrF3Disabled) {
Expand All @@ -400,8 +400,8 @@ func F3Participation(mctx helpers.MetricsCtx, lc fx.Lifecycle, api v1api.FullNod
log.Errorf("lotus node refused our lease, are you loadbalancing or did the miner just restart?")

sleepFor := b.Duration()
if time.Until(oldLease) > 0 {
sleepFor = min(sleepFor, time.Until(oldLease))
if d := time.Until(oldLease); d > 0 && d < sleepFor {
sleepFor = d
}
timer.Reset(sleepFor)
select {
Expand Down

0 comments on commit 1a23d42

Please sign in to comment.