Skip to content

Commit

Permalink
f3: Don't bother checking the manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 25, 2024
1 parent f5ff54c commit 00a9ae6
Showing 1 changed file with 2 additions and 41 deletions.
43 changes: 2 additions & 41 deletions tasks/f3/f3_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func (f *F3Task) tryGetF3ParticipationTicket(ctx context.Context, stillOwned fun
func (f *F3Task) participateLoop(ctx context.Context, stillOwned func() bool, ticket api.F3ParticipationTicket) error {
renewLeaseWithin := f.leaseTerm / 2
var (
manifest *manifest.Manifest
haveLease bool
)
for stillOwned() {
Expand Down Expand Up @@ -177,50 +176,12 @@ func (f *F3Task) participateLoop(ctx context.Context, stillOwned func() bool, ti
}
}

// Fetch the manifest if necessary
if manifest == nil || lease.Network != manifest.NetworkName {
manifest, err = f.getManifest(ctx)
if err != nil {
return err
}
if manifest.NetworkName != lease.Network {
log.Warnf("Got a manifest for network %q while expecting network %q. Getting another ticket.", manifest.NetworkName, lease.Network)
return nil // Return to get a new ticket
}
}

// Wait until we think we may need to renew the lease
waitTime := time.Duration(lease.ValidityTerm-renewLeaseWithin) * manifest.CatchUpAlignment
if waitTime <= 0 {
waitTime = 100 * time.Millisecond
}
log.Debugf("F3 participation lease is valid for further %d instances. Re-checking after %s.", lease.ValidityTerm, waitTime)
time.Sleep(waitTime)
log.Debugf("F3 participation lease is valid for further %d instances.", lease.ValidityTerm)
time.Sleep(time.Second * 5)
}
return ctx.Err()
}

func (f *F3Task) getManifest(ctx context.Context) (*manifest.Manifest, error) {
for {
manifest, err := f.api.F3GetManifest(ctx)
switch {
case errors.Is(err, api.ErrF3Disabled):
log.Errorw("Cannot get F3 manifest as F3 is disabled.", "err", err)
return nil, xerrors.Errorf("getting F3 manifest: %w", err)
case err != nil:
log.Errorw("Failed to get F3 manifest. Retrying.", "err", err)
time.Sleep(1 * time.Second)
continue
case manifest == nil:
log.Warnw("Received no F3 manifest from lotus. Retrying.", "err", err)
time.Sleep(1 * time.Second)
continue
default:
return manifest, nil
}
}
}

func (f *F3Task) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEngine) (*harmonytask.TaskID, error) {
id := ids[0]
return &id, nil
Expand Down

0 comments on commit 00a9ae6

Please sign in to comment.