Skip to content

Commit f614e7a

Browse files
committed
sweep: add createUnknownSpentBumpResult
A minor refactor to break the method `handleUnknownSpent` into two steps, which prepares the following commit where we start handling missing inputs.
1 parent db8319d commit f614e7a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

sweep/fee_bumper.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,19 @@ func (t *TxPublisher) handleUnknownSpent(r *monitorRecord) {
11701170
"bumper, failing it now:\n%v", r.requestID,
11711171
inputTypeSummary(r.req.Inputs))
11721172

1173+
// Create a result that will be sent to the resultChan which is listened
1174+
// by the caller.
1175+
result := t.createUnknownSpentBumpResult(r)
1176+
1177+
// Notify the sweeper about this result in the end.
1178+
t.handleResult(result)
1179+
}
1180+
1181+
// createUnknownSpentBumpResult creates and returns a BumpResult given the
1182+
// monitored record has unknown spends.
1183+
func (t *TxPublisher) createUnknownSpentBumpResult(
1184+
r *monitorRecord) *BumpResult {
1185+
11731186
// Create a result that will be sent to the resultChan which is listened
11741187
// by the caller.
11751188
result := &BumpResult{
@@ -1208,10 +1221,7 @@ func (t *TxPublisher) handleUnknownSpent(r *monitorRecord) {
12081221
result.Event = TxFatal
12091222
result.Err = err
12101223

1211-
// Notify the sweeper about this result in the end.
1212-
t.handleResult(result)
1213-
1214-
return
1224+
return result
12151225
}
12161226

12171227
feeFunc = f
@@ -1234,8 +1244,7 @@ func (t *TxPublisher) handleUnknownSpent(r *monitorRecord) {
12341244
// Attach the new fee rate to be used for the next sweeping attempt.
12351245
result.FeeRate = feeFunc.FeeRate()
12361246

1237-
// Notify the sweeper about this result in the end.
1238-
t.handleResult(result)
1247+
return result
12391248
}
12401249

12411250
// createAndPublishTx creates a new tx with a higher fee rate and publishes it

0 commit comments

Comments
 (0)