lnrpc+sweep: rename Force to Immediate for clarity

This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:37 +08:00
1 parent 19a599a1a9
commit db3aad31aa
9 files changed
+484 -435

No files matched your search

+3 -3
View File
@@ -77,7 +77,7 @@ func (c *inputCluster) createInputSets(maxFeeRate chainfee.SatPerKWeight,
// that is described above, we place force sweeps at the start
// of the list. Otherwise we can't be sure that they will be
// included in an input set.
if inputList[i].parameters().Force {
if inputList[i].parameters().Immediate {
return true
}
@@ -701,8 +701,8 @@ func (b *BudgetAggregator) sortInputs(inputs []SweeperInput) []SweeperInput {
right := sortedInputs[j].params.Budget
// Make sure forced inputs are always put in the front.
leftForce := sortedInputs[i].params.Force
rightForce := sortedInputs[j].params.Force
leftForce := sortedInputs[i].params.Immediate
rightForce := sortedInputs[j].params.Immediate
// If both are forced inputs, we return the one with the higher
// budget. If neither are forced inputs, we also return the one
+4 -4
View File
@@ -582,8 +582,8 @@ func TestBudgetAggregatorSortInputs(t *testing.T) {
// Create an input with the low budget but forced.
inputLowForce := SweeperInput{
params: Params{
Budget: budgetLow,
Force: true,
Budget: budgetLow,
Immediate: true,
},
}
@@ -597,8 +597,8 @@ func TestBudgetAggregatorSortInputs(t *testing.T) {
// Create an input with the high budget and forced.
inputHighForce := SweeperInput{
params: Params{
Budget: budgetHight,
Force: true,
Budget: budgetHight,
Immediate: true,
},
}
+12 -13
View File
@@ -48,12 +48,6 @@ type Params struct {
// a fee rate whenever we attempt to cluster inputs for a sweep.
Fee FeePreference
// Force indicates whether the input should be swept regardless of
// whether it is economical to do so.
//
// TODO(yy): Remove this param once deadline based sweeping is in place.
Force bool
// ExclusiveGroup is an identifier that, if set, prevents other inputs
// with the same identifier from being batched together.
ExclusiveGroup *uint64
@@ -66,6 +60,11 @@ type Params struct {
// Budget specifies the maximum amount of satoshis that can be spent on
// fees for this sweep.
Budget btcutil.Amount
// Immediate indicates that the input should be swept immediately
// without waiting for blocks to come to trigger the sweeping of
// inputs.
Immediate bool
}
// ParamsUpdate contains a new set of parameters to update a pending sweep with.
@@ -75,9 +74,9 @@ type ParamsUpdate struct {
// a fee rate whenever we attempt to cluster inputs for a sweep.
Fee FeePreference
// Force indicates whether the input should be swept regardless of
// whether it is economical to do so.
Force bool
// Immediate indicates that the input should be swept immediately
// without waiting for blocks to come.
Immediate bool
}
// String returns a human readable interpretation of the sweep parameters.
@@ -92,8 +91,8 @@ func (p Params) String() string {
exclusiveGroup = fmt.Sprintf("%d", *p.ExclusiveGroup)
}
return fmt.Sprintf("fee=%v, force=%v, exclusive_group=%v, budget=%v, "+
"deadline=%v", p.Fee, p.Force, exclusiveGroup, p.Budget,
return fmt.Sprintf("fee=%v, immediate=%v, exclusive_group=%v, budget=%v, "+
"deadline=%v", p.Fee, p.Immediate, exclusiveGroup, p.Budget,
deadline)
}
@@ -669,7 +668,7 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
// If this input is forced, we perform an sweep
// immediately.
if input.params.Force {
if input.params.Immediate {
inputs := s.updateSweeperInputs()
s.sweepPendingInputs(inputs)
}
@@ -1144,7 +1143,7 @@ func (s *UtxoSweeper) handleUpdateReq(req *updateReq) (
// unchanged.
newParams := sweeperInput.params
newParams.Fee = req.params.Fee
newParams.Force = req.params.Force
newParams.Immediate = req.params.Immediate
log.Debugf("Updating parameters for %v(state=%v) from (%v) to (%v)",
req.input, sweeperInput.state, sweeperInput.params, newParams)
+1 -1
View File
@@ -406,7 +406,7 @@ func (t *txInputSet) addPositiveYieldInputs(sweepableInputs []*SweeperInput) {
for i, inp := range sweepableInputs {
// Apply relaxed constraints for force sweeps.
constraints := constraintsRegular
if inp.parameters().Force {
if inp.parameters().Immediate {
constraints = constraintsForce
}