mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
sweepbatcher: always try greedy batch selection
Now that sweep.minFeeRate is always set, greedy batch selection has all needed inputs to work even without customFeeRate provider.
This commit is contained in:
parent
75641c3573
commit
026cf0d47a
2 changed files with 8 additions and 16 deletions
|
|
@ -28,11 +28,6 @@ import (
|
|||
// creation fails, this method returns an error. If this method fails for any
|
||||
// reason, the caller falls back to the simple algorithm (method handleSweep).
|
||||
func (b *Batcher) greedyAddSweep(ctx context.Context, sweep *sweep) error {
|
||||
if b.customFeeRate == nil {
|
||||
return errors.New("greedy batch selection algorithm requires " +
|
||||
"setting custom fee rate provider")
|
||||
}
|
||||
|
||||
// Collect weight and fee rate info about the sweep and new batch.
|
||||
sweepFeeDetails, newBatchFeeDetails, err := estimateSweepFeeIncrement(
|
||||
sweep,
|
||||
|
|
|
|||
|
|
@ -474,19 +474,16 @@ func (b *Batcher) handleSweep(ctx context.Context, sweep *sweep,
|
|||
}
|
||||
}
|
||||
|
||||
// If custom fee rate provider is used, run the greedy algorithm of
|
||||
// batch selection to minimize costs.
|
||||
if b.customFeeRate != nil {
|
||||
err := b.greedyAddSweep(ctx, sweep)
|
||||
if err == nil {
|
||||
// The greedy algorithm succeeded.
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Warnf("Greedy batch selection algorithm failed for sweep "+
|
||||
"%x, falling back to old approach.", sweep.swapHash[:6])
|
||||
// Try to run the greedy algorithm of batch selection to minimize costs.
|
||||
err = b.greedyAddSweep(ctx, sweep)
|
||||
if err == nil {
|
||||
// The greedy algorithm succeeded.
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Warnf("Greedy batch selection algorithm failed for sweep %x: %v. "+
|
||||
"Falling back to old approach.", sweep.swapHash[:6], err)
|
||||
|
||||
// If one of the batches accepts the sweep, we provide it to that batch.
|
||||
for _, batch := range b.batches {
|
||||
accepted, err := batch.addSweep(ctx, sweep)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue