sweep: extract sweepCluster method
Prepares for adding another level of nesting.
This commit is contained in:
parent
34c9193bfc
commit
8353b6fd6e
@ -599,27 +599,10 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
|
|||||||
inputClusters[j].sweepFeeRate
|
inputClusters[j].sweepFeeRate
|
||||||
})
|
})
|
||||||
for _, cluster := range inputClusters {
|
for _, cluster := range inputClusters {
|
||||||
// Examine pending inputs and try to construct
|
err := s.sweepCluster(cluster, bestHeight)
|
||||||
// lists of inputs.
|
|
||||||
inputLists, err := s.getInputLists(
|
|
||||||
cluster, bestHeight,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Unable to examine pending "+
|
log.Errorf("input cluster sweep: %v",
|
||||||
"inputs: %v", err)
|
err)
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sweep selected inputs.
|
|
||||||
for _, inputs := range inputLists {
|
|
||||||
err := s.sweep(
|
|
||||||
inputs, cluster.sweepFeeRate,
|
|
||||||
bestHeight,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("Unable to sweep "+
|
|
||||||
"inputs: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,6 +628,27 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sweepCluster tries to sweep the given input cluster.
|
||||||
|
func (s *UtxoSweeper) sweepCluster(cluster inputCluster,
|
||||||
|
currentHeight int32) error {
|
||||||
|
|
||||||
|
// Examine pending inputs and try to construct lists of inputs.
|
||||||
|
inputLists, err := s.getInputLists(cluster, currentHeight)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to examine pending inputs: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sweep selected inputs.
|
||||||
|
for _, inputs := range inputLists {
|
||||||
|
err := s.sweep(inputs, cluster.sweepFeeRate, currentHeight)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to sweep inputs: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// bucketForFeeReate determines the proper bucket for a fee rate. This is done
|
// bucketForFeeReate determines the proper bucket for a fee rate. This is done
|
||||||
// in order to batch inputs with similar fee rates together.
|
// in order to batch inputs with similar fee rates together.
|
||||||
func (s *UtxoSweeper) bucketForFeeRate(
|
func (s *UtxoSweeper) bucketForFeeRate(
|
||||||
|
Loading…
Reference in New Issue
Block a user