sweep: change MaxInputsPerTx from int to uint32

This commit is contained in:
yyforyongyu 2024-03-20 05:56:56 +08:00
parent 521b1fc34a
commit d0a8f27d84
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
5 changed files with 9 additions and 9 deletions

View file

@ -35,7 +35,7 @@ type inputCluster struct {
// inputs are skipped. No input sets with a total value after fees below the
// dust limit are returned.
func (c *inputCluster) createInputSets(maxFeeRate chainfee.SatPerKWeight,
maxInputs int) []InputSet {
maxInputs uint32) []InputSet {
// Turn the inputs into a slice so we can sort them.
inputList := make([]*pendingInput, 0, len(c.inputs))
@ -138,7 +138,7 @@ type SimpleAggregator struct {
// MaxInputsPerTx specifies the default maximum number of inputs allowed
// in a single sweep tx. If more need to be swept, multiple txes are
// created and published.
MaxInputsPerTx int
MaxInputsPerTx uint32
// FeeRateBucketSize is the default size of fee rate buckets we'll use
// when clustering inputs into buckets with similar fee rates within
@ -158,7 +158,7 @@ var _ UtxoAggregator = (*SimpleAggregator)(nil)
// NewSimpleUtxoAggregator creates a new instance of a SimpleAggregator.
func NewSimpleUtxoAggregator(estimator chainfee.Estimator,
max chainfee.SatPerKWeight, maxTx int) *SimpleAggregator {
max chainfee.SatPerKWeight, maxTx uint32) *SimpleAggregator {
return &SimpleAggregator{
FeeEstimator: estimator,

View file

@ -335,7 +335,7 @@ type UtxoSweeperConfig struct {
// MaxInputsPerTx specifies the default maximum number of inputs allowed
// in a single sweep tx. If more need to be swept, multiple txes are
// created and published.
MaxInputsPerTx int
MaxInputsPerTx uint32
// MaxSweepAttempts specifies the maximum number of times an input is
// included in a publish attempt before giving up and returning an error

View file

@ -30,7 +30,7 @@ var (
testMaxSweepAttempts = 3
testMaxInputsPerTx = 3
testMaxInputsPerTx = uint32(3)
defaultFeePref = Params{Fee: FeeEstimateInfo{ConfTarget: 1}}
)

View file

@ -139,7 +139,7 @@ type txInputSet struct {
// maxInputs is the maximum number of inputs that will be accepted in
// the set.
maxInputs int
maxInputs uint32
}
// Compile-time constraint to ensure txInputSet implements InputSet.
@ -147,7 +147,7 @@ var _ InputSet = (*txInputSet)(nil)
// newTxInputSet constructs a new, empty input set.
func newTxInputSet(feePerKW, maxFeeRate chainfee.SatPerKWeight,
maxInputs int) *txInputSet {
maxInputs uint32) *txInputSet {
state := txInputSetState{
feeRate: feePerKW,
@ -215,7 +215,7 @@ func (t *txInputSet) addToState(inp input.Input,
// Stop if max inputs is reached. Do not count additional wallet inputs,
// because we don't know in advance how many we may need.
if constraints != constraintsWallet &&
len(t.inputs) >= t.maxInputs {
uint32(len(t.inputs)) >= t.maxInputs {
return nil
}

View file

@ -19,7 +19,7 @@ var (
// DefaultMaxInputsPerTx specifies the default maximum number of inputs
// allowed in a single sweep tx. If more need to be swept, multiple txes
// are created and published.
DefaultMaxInputsPerTx = 100
DefaultMaxInputsPerTx = uint32(100)
// ErrLocktimeConflict is returned when inputs with different
// transaction nLockTime values are included in the same transaction.