sweep: pass default deadline height when clustering inputs

This commit changes the method `ClusterInputs` to also take a default
deadline height. Previously, when calculating the default deadline
height for a non-time sensitive input, we would first cluster it with
other non-time sensitive inputs, then give it a deadline before we are
about to `sweep`. This is now moved to the step where we decide to
cluster inputs, allowing time-sensitive and non-sensitive inputs to be
grouped together, if they happen to share the same deadline heights.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:32 +08:00
1 parent 15588355b3
commit 4c13ea1747
7 files changed
+80 -69

No files matched your search

+6 -7
View File
@@ -817,18 +817,13 @@ func (s *UtxoSweeper) sweep(set InputSet) error {
s.currentOutputScript = pkScript
}
// Create a default deadline height, and replace it with set's
// DeadlineHeight if it's set.
deadlineHeight := s.currentHeight + DefaultDeadlineDelta
deadlineHeight = set.DeadlineHeight().UnwrapOr(deadlineHeight)
// Create a fee bump request and ask the publisher to broadcast it. The
// publisher will then take over and start monitoring the tx for
// potential fee bump.
req := &BumpRequest{
Inputs: set.Inputs(),
Budget: set.Budget(),
DeadlineHeight: deadlineHeight,
DeadlineHeight: set.DeadlineHeight(),
DeliveryAddress: s.currentOutputScript,
MaxFeeRate: s.cfg.MaxFeeRate.FeePerKWeight(),
// TODO(yy): pass the strategy here.
@@ -1554,8 +1549,12 @@ func (s *UtxoSweeper) updateSweeperInputs() InputsMap {
// sweepPendingInputs is called when the ticker fires. It will create clusters
// and attempt to create and publish the sweeping transactions.
func (s *UtxoSweeper) sweepPendingInputs(inputs InputsMap) {
// Create a default deadline height, which will be used when there's no
// DeadlineHeight specified for a given input.
defaultDeadline := s.currentHeight + DefaultDeadlineDelta
// Cluster all of our inputs based on the specific Aggregator.
sets := s.cfg.Aggregator.ClusterInputs(inputs)
sets := s.cfg.Aggregator.ClusterInputs(inputs, defaultDeadline)
// sweepWithLock is a helper closure that executes the sweep within a
// coin select lock to prevent the coins being selected for other