mirror of https://github.com/BTCPrivate/lnd.git
pilot: fix goroutine leak by also draining UnconfirmedTransactions notifications
This commit is contained in:
parent
95de109844
commit
e19614ff3f
18
pilot.go
18
pilot.go
|
@ -197,6 +197,24 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
defer txnSubscription.Cancel()
|
||||||
|
defer svr.wg.Done()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
// We won't act upon new unconfirmed transaction, as
|
||||||
|
// we'll only use confirmed outputs when funding.
|
||||||
|
// However, we will still drain this request in order
|
||||||
|
// to avoid goroutine leaks, and ensure we promptly
|
||||||
|
// read from the channel if available.
|
||||||
|
case <-txnSubscription.UnconfirmedTransactions():
|
||||||
|
case <-svr.quit:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// We'll also launch a goroutine to provide the agent with
|
// We'll also launch a goroutine to provide the agent with
|
||||||
|
|
Loading…
Reference in New Issue