Skip to content

Commit

Permalink
sweepbatcher: use coopFailed in greedy selection
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
starius committed Jul 26, 2024
1 parent 29a933e commit 06ad56e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sweepbatcher/greedy_batch_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func estimateSweepFeeIncrement(s *sweep) (feeDetails, feeDetails, error) {
// Create feeDetails for sweep.
sweepFeeDetails := feeDetails{
FeeRate: s.minFeeRate,
NonCoopHint: s.nonCoopHint,
NonCoopHint: s.nonCoopHint || s.coopFailed,
IsExternalAddr: s.isExternalAddr,

// Calculate sweep weight as a difference.
Expand All @@ -152,7 +152,7 @@ func estimateBatchWeight(batch *batch) (feeDetails, error) {
// Find if the batch has at least one non-cooperative sweep.
hasNonCoop := false
for _, sweep := range batch.sweeps {
if sweep.nonCoopHint {
if sweep.nonCoopHint || sweep.coopFailed {
hasNonCoop = true
}
}
Expand Down
47 changes: 47 additions & 0 deletions sweepbatcher/greedy_batch_selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,27 @@ func TestEstimateSweepFeeIncrement(t *testing.T) {
NonCoopHint: true,
},
},

{
name: "coop-failed",
sweep: &sweep{
minFeeRate: lowFeeRate,
htlcSuccessEstimator: se3,
coopFailed: true,
},
wantSweepFeeDetails: feeDetails{
FeeRate: lowFeeRate,
CoopWeight: coopInputWeight,
NonCoopWeight: nonCoopInputWeight,
NonCoopHint: true,
},
wantNewBatchFeeDetails: feeDetails{
FeeRate: lowFeeRate,
CoopWeight: coopNewBatchWeight,
NonCoopWeight: nonCoopNewBatchWeight,
NonCoopHint: true,
},
},
}

for _, tc := range cases {
Expand Down Expand Up @@ -330,6 +351,32 @@ func TestEstimateBatchWeight(t *testing.T) {
},
},

{
name: "coop-failed",
batch: &batch{
id: 1,
rbfCache: rbfCache{
FeeRate: lowFeeRate,
},
sweeps: map[lntypes.Hash]sweep{
swapHash1: {
htlcSuccessEstimator: se3,
},
swapHash2: {
htlcSuccessEstimator: se3,
coopFailed: true,
},
},
},
wantBatchFeeDetails: feeDetails{
BatchId: 1,
FeeRate: lowFeeRate,
CoopWeight: coopTwoSweepBatchWeight,
NonCoopWeight: nonCoopTwoSweepBatchWeight,
NonCoopHint: true,
},
},

{
name: "isExternalAddr",
batch: &batch{
Expand Down

0 comments on commit 06ad56e

Please sign in to comment.