mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
autopilot: revert passing ctx to Start methods
This commit is contained in:
@@ -202,10 +202,10 @@ func New(cfg Config, initialState []LocalChannel) (*Agent, error) {
|
||||
|
||||
// Start starts the agent along with any goroutines it needs to perform its
|
||||
// normal duties.
|
||||
func (a *Agent) Start(ctx context.Context) error {
|
||||
func (a *Agent) Start() error {
|
||||
var err error
|
||||
a.started.Do(func() {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
a.cancel = fn.Some(cancel)
|
||||
|
||||
err = a.start(ctx)
|
||||
|
@@ -221,7 +221,7 @@ func setup(t *testing.T, initialChans []LocalChannel) *testContext {
|
||||
|
||||
// With the autopilot agent and all its dependencies we'll start the
|
||||
// primary controller goroutine.
|
||||
if err := agent.Start(context.Background()); err != nil {
|
||||
if err := agent.Start(); err != nil {
|
||||
t.Fatalf("unable to start agent: %v", err)
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -55,9 +54,8 @@ type Manager struct {
|
||||
// disabled.
|
||||
pilot *Agent
|
||||
|
||||
quit chan struct{}
|
||||
wg sync.WaitGroup
|
||||
cancel fn.Option[context.CancelFunc]
|
||||
quit chan struct{}
|
||||
wg sync.WaitGroup
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
@@ -83,7 +81,6 @@ func (m *Manager) Stop() error {
|
||||
log.Errorf("Unable to stop pilot: %v", err)
|
||||
}
|
||||
|
||||
m.cancel.WhenSome(func(fn context.CancelFunc) { fn() })
|
||||
close(m.quit)
|
||||
m.wg.Wait()
|
||||
})
|
||||
@@ -100,7 +97,7 @@ func (m *Manager) IsActive() bool {
|
||||
|
||||
// StartAgent creates and starts an autopilot agent from the Manager's
|
||||
// config.
|
||||
func (m *Manager) StartAgent(ctx context.Context) error {
|
||||
func (m *Manager) StartAgent() error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
@@ -108,8 +105,6 @@ func (m *Manager) StartAgent(ctx context.Context) error {
|
||||
if m.pilot != nil {
|
||||
return nil
|
||||
}
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
m.cancel = fn.Some(cancel)
|
||||
|
||||
// Next, we'll fetch the current state of open channels from the
|
||||
// database to use as initial state for the auto-pilot agent.
|
||||
@@ -125,7 +120,7 @@ func (m *Manager) StartAgent(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := pilot.Start(ctx); err != nil {
|
||||
if err := pilot.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -169,8 +164,6 @@ func (m *Manager) StartAgent(ctx context.Context) error {
|
||||
return
|
||||
case <-m.quit:
|
||||
return
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +234,6 @@ func (m *Manager) StartAgent(ctx context.Context) error {
|
||||
return
|
||||
case <-m.quit:
|
||||
return
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Reference in New Issue
Block a user