sweep: exit when handleNewInput fails
When `handleNewInput` fails, it means there's something terribly wrong with the chain backend, which means we need to stop the current process and let user handle it.
This commit is contained in:
1 file changed
+12
-4
+12
-4
@@ -657,7 +657,13 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
|
|||||||
// we are already trying to sweep this input and if not, set up
|
// we are already trying to sweep this input and if not, set up
|
||||||
// a listener to spend and schedule a sweep.
|
// a listener to spend and schedule a sweep.
|
||||||
case input := <-s.newInputs:
|
case input := <-s.newInputs:
|
||||||
s.handleNewInput(input)
|
err := s.handleNewInput(input)
|
||||||
|
if err != nil {
|
||||||
|
log.Criticalf("Unable to handle new input: %v",
|
||||||
|
err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// If this input is forced, we perform an sweep
|
// If this input is forced, we perform an sweep
|
||||||
// immediately.
|
// immediately.
|
||||||
@@ -1221,7 +1227,7 @@ func (s *UtxoSweeper) mempoolLookup(op wire.OutPoint) fn.Option[wire.MsgTx] {
|
|||||||
|
|
||||||
// handleNewInput processes a new input by registering spend notification and
|
// handleNewInput processes a new input by registering spend notification and
|
||||||
// scheduling sweeping for it.
|
// scheduling sweeping for it.
|
||||||
func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) error {
|
||||||
outpoint := input.input.OutPoint()
|
outpoint := input.input.OutPoint()
|
||||||
pi, pending := s.inputs[outpoint]
|
pi, pending := s.inputs[outpoint]
|
||||||
if pending {
|
if pending {
|
||||||
@@ -1229,7 +1235,7 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
|||||||
|
|
||||||
s.handleExistingInput(input, pi)
|
s.handleExistingInput(input, pi)
|
||||||
|
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a new input, and we want to query the mempool to see if this
|
// This is a new input, and we want to query the mempool to see if this
|
||||||
@@ -1261,10 +1267,12 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) {
|
|||||||
err := fmt.Errorf("wait for spend: %w", err)
|
err := fmt.Errorf("wait for spend: %w", err)
|
||||||
s.markInputFailed(pi, err)
|
s.markInputFailed(pi, err)
|
||||||
|
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pi.ntfnRegCancel = cancel
|
pi.ntfnRegCancel = cancel
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// decideStateAndRBFInfo queries the mempool to see whether the given input has
|
// decideStateAndRBFInfo queries the mempool to see whether the given input has
|
||||||
|
|||||||
Reference in new issue
Block a user