Skip to content

Commit

Permalink
Merge pull request #1011 from SiaFoundation/pj/improve-ap-logger-noise
Browse files Browse the repository at this point in the history
Reduce logger noise
  • Loading branch information
ChrisSchinnerl authored Feb 29, 2024
2 parents 85141d3 + 96bb6ef commit a10da6f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions autopilot/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ func (ap *Autopilot) Run() error {

// schedule a trigger when the wallet receives its first deposit
if err := ap.tryScheduleTriggerWhenFunded(); err != nil {
ap.logger.Error(err)
if !errors.Is(err, context.Canceled) {
ap.logger.Error(err)
}
return nil
}

var forceScan bool
var launchAccountRefillsOnce sync.Once
for {
for !ap.isStopped() {
ap.logger.Info("autopilot iteration starting")
tickerFired := make(chan struct{})
ap.workers.withWorker(func(w Worker) {
Expand All @@ -220,7 +222,7 @@ func (ap *Autopilot) Run() error {
close(tickerFired)
return
}
ap.logger.Error("autopilot stopped before consensus was synced")
ap.logger.Info("autopilot stopped before consensus was synced")
return
} else if blocked {
if scanning, _ := ap.s.Status(); !scanning {
Expand All @@ -234,7 +236,7 @@ func (ap *Autopilot) Run() error {
close(tickerFired)
return
}
ap.logger.Error("autopilot stopped before it was able to confirm it was configured in the bus")
ap.logger.Info("autopilot stopped before it was able to confirm it was configured in the bus")
return
}

Expand Down Expand Up @@ -308,6 +310,7 @@ func (ap *Autopilot) Run() error {
case <-tickerFired:
}
}
return nil
}

// Shutdown shuts down the autopilot.
Expand Down Expand Up @@ -463,11 +466,12 @@ func (ap *Autopilot) blockUntilSynced(interrupt <-chan time.Time) (synced, block
}

func (ap *Autopilot) tryScheduleTriggerWhenFunded() error {
ctx, cancel := context.WithTimeout(ap.shutdownCtx, 30*time.Second)
wallet, err := ap.bus.Wallet(ctx)
cancel()
// apply sane timeout
ctx, cancel := context.WithTimeout(ap.shutdownCtx, time.Minute)
defer cancel()

// no need to schedule a trigger if the wallet is already funded
wallet, err := ap.bus.Wallet(ctx)
if err != nil {
return err
} else if !wallet.Confirmed.Add(wallet.Unconfirmed).IsZero() {
Expand Down

0 comments on commit a10da6f

Please sign in to comment.