From 3ac6752a778307fc0223fca29fdf61a38319fb3c Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 18 Nov 2024 11:09:21 +0800 Subject: [PATCH] sweep: remove redundant notifications during shutdown This commit removes the hack introduced in #4851. Previously we had this issue because the chain notifier was stopped before the sweeper, which was changed a while back and we now always stop the chain notifier last. In addition, since we no longer subscribe to the block epoch chan directly, this issue can no longer happen. --- sweep/sweeper.go | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/sweep/sweeper.go b/sweep/sweeper.go index 64306935c..b91a6808f 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -454,38 +454,7 @@ func (s *UtxoSweeper) Start() error { // Start sweeper main loop. s.wg.Add(1) - go func() { - defer s.wg.Done() - - s.collector() - - // The collector exited and won't longer handle incoming - // requests. This can happen on shutdown, when the block - // notifier shuts down before the sweeper and its clients. In - // order to not deadlock the clients waiting for their requests - // being handled, we handle them here and immediately return an - // error. When the sweeper finally is shut down we can exit as - // the clients will be notified. - for { - select { - case inp := <-s.newInputs: - inp.resultChan <- Result{ - Err: ErrSweeperShuttingDown, - } - - case req := <-s.pendingSweepsReqs: - req.errChan <- ErrSweeperShuttingDown - - case req := <-s.updateReqs: - req.responseChan <- &updateResp{ - err: ErrSweeperShuttingDown, - } - - case <-s.quit: - return - } - } - }() + go s.collector() return nil }