mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 21:51:27 +02:00
sweep: remove block subscription in UtxoSweeper
and TxPublisher
This commit removes the independent block subscriptions in `UtxoSweeper` and `TxPublisher`. These subsystems now listen to the `BlockbeatChan` for new blocks.
This commit is contained in:
@@ -802,13 +802,8 @@ func (t *TxPublisher) Start() error {
|
||||
return fmt.Errorf("TxPublisher started more than once")
|
||||
}
|
||||
|
||||
blockEvent, err := t.cfg.Notifier.RegisterBlockEpochNtfn(nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("register block epoch ntfn: %w", err)
|
||||
}
|
||||
|
||||
t.wg.Add(1)
|
||||
go t.monitor(blockEvent)
|
||||
go t.monitor()
|
||||
|
||||
log.Debugf("TxPublisher started")
|
||||
|
||||
@@ -836,33 +831,25 @@ func (t *TxPublisher) Stop() error {
|
||||
// to be bumped. If so, it will attempt to bump the fee of the tx.
|
||||
//
|
||||
// NOTE: Must be run as a goroutine.
|
||||
func (t *TxPublisher) monitor(blockEvent *chainntnfs.BlockEpochEvent) {
|
||||
defer blockEvent.Cancel()
|
||||
func (t *TxPublisher) monitor() {
|
||||
defer t.wg.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
case epoch, ok := <-blockEvent.Epochs:
|
||||
if !ok {
|
||||
// We should stop the publisher before stopping
|
||||
// the chain service. Otherwise it indicates an
|
||||
// error.
|
||||
log.Error("Block epoch channel closed, exit " +
|
||||
"monitor")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("TxPublisher received new block: %v",
|
||||
epoch.Height)
|
||||
case beat := <-t.BlockbeatChan:
|
||||
height := beat.Height()
|
||||
log.Debugf("TxPublisher received new block: %v", height)
|
||||
|
||||
// Update the best known height for the publisher.
|
||||
t.currentHeight.Store(epoch.Height)
|
||||
t.currentHeight.Store(height)
|
||||
|
||||
// Check all monitored txns to see if any of them needs
|
||||
// to be bumped.
|
||||
t.processRecords()
|
||||
|
||||
// Notify we've processed the block.
|
||||
t.NotifyBlockProcessed(beat, nil)
|
||||
|
||||
case <-t.quit:
|
||||
log.Debug("Fee bumper stopped, exit monitor")
|
||||
return
|
||||
|
Reference in New Issue
Block a user