mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-28 01:32:27 +02:00
sweep: remove redundant map inputFeeRates
when creating cluster
This commit removes the map `inputFeeRates` inside `clusterByLockTime` as the fee rate can already be access via `input.lastFeeRate`.
This commit is contained in:
parent
497f421009
commit
a46168e669
@ -928,7 +928,6 @@ func (s *UtxoSweeper) clusterByLockTime(inputs pendingInputs) ([]inputCluster,
|
|||||||
pendingInputs) {
|
pendingInputs) {
|
||||||
|
|
||||||
locktimes := make(map[uint32]pendingInputs)
|
locktimes := make(map[uint32]pendingInputs)
|
||||||
inputFeeRates := make(map[wire.OutPoint]chainfee.SatPerKWeight)
|
|
||||||
rem := make(pendingInputs)
|
rem := make(pendingInputs)
|
||||||
|
|
||||||
// Go through all inputs and check if they require a certain locktime.
|
// Go through all inputs and check if they require a certain locktime.
|
||||||
@ -940,13 +939,13 @@ func (s *UtxoSweeper) clusterByLockTime(inputs pendingInputs) ([]inputCluster,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if we already have inputs with this locktime.
|
// Check if we already have inputs with this locktime.
|
||||||
p, ok := locktimes[lt]
|
cluster, ok := locktimes[lt]
|
||||||
if !ok {
|
if !ok {
|
||||||
p = make(pendingInputs)
|
cluster = make(pendingInputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
p[op] = input
|
cluster[op] = input
|
||||||
locktimes[lt] = p
|
locktimes[lt] = cluster
|
||||||
|
|
||||||
// We also get the preferred fee rate for this input.
|
// We also get the preferred fee rate for this input.
|
||||||
feeRate, err := s.feeRateForPreference(input.params.Fee)
|
feeRate, err := s.feeRateForPreference(input.params.Fee)
|
||||||
@ -956,25 +955,24 @@ func (s *UtxoSweeper) clusterByLockTime(inputs pendingInputs) ([]inputCluster,
|
|||||||
}
|
}
|
||||||
|
|
||||||
input.lastFeeRate = feeRate
|
input.lastFeeRate = feeRate
|
||||||
inputFeeRates[op] = feeRate
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll then determine the sweep fee rate for each set of inputs by
|
// We'll then determine the sweep fee rate for each set of inputs by
|
||||||
// calculating the average fee rate of the inputs within each set.
|
// calculating the average fee rate of the inputs within each set.
|
||||||
inputClusters := make([]inputCluster, 0, len(locktimes))
|
inputClusters := make([]inputCluster, 0, len(locktimes))
|
||||||
for lt, inputs := range locktimes {
|
for lt, cluster := range locktimes {
|
||||||
lt := lt
|
lt := lt
|
||||||
|
|
||||||
var sweepFeeRate chainfee.SatPerKWeight
|
var sweepFeeRate chainfee.SatPerKWeight
|
||||||
for op := range inputs {
|
for _, input := range cluster {
|
||||||
sweepFeeRate += inputFeeRates[op]
|
sweepFeeRate += input.lastFeeRate
|
||||||
}
|
}
|
||||||
|
|
||||||
sweepFeeRate /= chainfee.SatPerKWeight(len(inputs))
|
sweepFeeRate /= chainfee.SatPerKWeight(len(cluster))
|
||||||
inputClusters = append(inputClusters, inputCluster{
|
inputClusters = append(inputClusters, inputCluster{
|
||||||
lockTime: <,
|
lockTime: <,
|
||||||
sweepFeeRate: sweepFeeRate,
|
sweepFeeRate: sweepFeeRate,
|
||||||
inputs: inputs,
|
inputs: cluster,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user