2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-09 19:10:47 +00:00

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.
This commit is contained in:
Boris Nagaev 2024-07-26 14:24:38 -03:00
parent 26eda00ef2
commit d007cf6e20
No known key found for this signature in database
2 changed files with 49 additions and 2 deletions

View File

@ -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.
@ -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
}
}

View File

@ -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 {
@ -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{