lnd: init publisher when creating new server

This commit is contained in:
yyforyongyu 2024-03-17 14:11:04 +08:00
parent 90e727a776
commit 23feef7e6c
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

View File

@ -326,6 +326,9 @@ type server struct {
customMessageServer *subscribe.Server
// txPublisher is a publisher with fee-bumping capability.
txPublisher *sweep.TxPublisher
quit chan struct{}
wg sync.WaitGroup
@ -1065,6 +1068,13 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
sweep.DefaultMaxInputsPerTx,
)
s.txPublisher = sweep.NewTxPublisher(sweep.TxPublisherConfig{
Signer: cc.Wallet.Cfg.Signer,
Wallet: cc.Wallet,
Estimator: cc.FeeEstimator,
Notifier: cc.ChainNotifier,
})
s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{
FeeEstimator: cc.FeeEstimator,
GenSweepScript: newSweepPkScriptGen(cc.Wallet),
@ -1077,6 +1087,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
MaxSweepAttempts: sweep.DefaultMaxSweepAttempts,
MaxFeeRate: cfg.Sweeper.MaxFeeRate,
Aggregator: aggregator,
Publisher: s.txPublisher,
})
s.utxoNursery = contractcourt.NewUtxoNursery(&contractcourt.NurseryConfig{
@ -1931,6 +1942,15 @@ func (s *server) Start() error {
cleanup = cleanup.add(s.towerClientMgr.Stop)
}
if err := s.txPublisher.Start(); err != nil {
startErr = err
return
}
cleanup = cleanup.add(func() error {
s.txPublisher.Stop()
return nil
})
if err := s.sweeper.Start(); err != nil {
startErr = err
return
@ -2264,6 +2284,9 @@ func (s *server) Stop() error {
if err := s.sweeper.Stop(); err != nil {
srvrLog.Warnf("failed to stop sweeper: %v", err)
}
s.txPublisher.Stop()
if err := s.channelNotifier.Stop(); err != nil {
srvrLog.Warnf("failed to stop channelNotifier: %v", err)
}