Skip to content

Commit d007cf6

Browse files
committed
sweepbatcher: use coopFailed in greedy selection
Treat coopFailed flag the same as nonCoopHint. The former is what we found in previos signing attempts, the later is what the caller signalled to us.
1 parent 26eda00 commit d007cf6

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

sweepbatcher/greedy_batch_selection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func estimateSweepFeeIncrement(s *sweep) (feeDetails, feeDetails, error) {
125125
// Create feeDetails for sweep.
126126
sweepFeeDetails := feeDetails{
127127
FeeRate: s.minFeeRate,
128-
NonCoopHint: s.nonCoopHint,
128+
NonCoopHint: s.nonCoopHint || s.coopFailed,
129129
IsExternalAddr: s.isExternalAddr,
130130

131131
// Calculate sweep weight as a difference.
@@ -152,7 +152,7 @@ func estimateBatchWeight(batch *batch) (feeDetails, error) {
152152
// Find if the batch has at least one non-cooperative sweep.
153153
hasNonCoop := false
154154
for _, sweep := range batch.sweeps {
155-
if sweep.nonCoopHint {
155+
if sweep.nonCoopHint || sweep.coopFailed {
156156
hasNonCoop = true
157157
}
158158
}

sweepbatcher/greedy_batch_selection_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,27 @@ func TestEstimateSweepFeeIncrement(t *testing.T) {
180180
NonCoopHint: true,
181181
},
182182
},
183+
184+
{
185+
name: "coop-failed",
186+
sweep: &sweep{
187+
minFeeRate: lowFeeRate,
188+
htlcSuccessEstimator: se3,
189+
coopFailed: true,
190+
},
191+
wantSweepFeeDetails: feeDetails{
192+
FeeRate: lowFeeRate,
193+
CoopWeight: coopInputWeight,
194+
NonCoopWeight: nonCoopInputWeight,
195+
NonCoopHint: true,
196+
},
197+
wantNewBatchFeeDetails: feeDetails{
198+
FeeRate: lowFeeRate,
199+
CoopWeight: coopNewBatchWeight,
200+
NonCoopWeight: nonCoopNewBatchWeight,
201+
NonCoopHint: true,
202+
},
203+
},
183204
}
184205

185206
for _, tc := range cases {
@@ -330,6 +351,32 @@ func TestEstimateBatchWeight(t *testing.T) {
330351
},
331352
},
332353

354+
{
355+
name: "coop-failed",
356+
batch: &batch{
357+
id: 1,
358+
rbfCache: rbfCache{
359+
FeeRate: lowFeeRate,
360+
},
361+
sweeps: map[lntypes.Hash]sweep{
362+
swapHash1: {
363+
htlcSuccessEstimator: se3,
364+
},
365+
swapHash2: {
366+
htlcSuccessEstimator: se3,
367+
coopFailed: true,
368+
},
369+
},
370+
},
371+
wantBatchFeeDetails: feeDetails{
372+
BatchId: 1,
373+
FeeRate: lowFeeRate,
374+
CoopWeight: coopTwoSweepBatchWeight,
375+
NonCoopWeight: nonCoopTwoSweepBatchWeight,
376+
NonCoopHint: true,
377+
},
378+
},
379+
333380
{
334381
name: "isExternalAddr",
335382
batch: &batch{

0 commit comments

Comments
 (0)