Skip to content

Commit 7295ca7

Browse files
committed
sweep: change MaxInputsPerTx from int to uint32
1 parent 0c36286 commit 7295ca7

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

sweep/aggregator.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type inputCluster struct {
3535
// inputs are skipped. No input sets with a total value after fees below the
3636
// dust limit are returned.
3737
func (c *inputCluster) createInputSets(maxFeeRate chainfee.SatPerKWeight,
38-
maxInputs int) []InputSet {
38+
maxInputs uint32) []InputSet {
3939

4040
// Turn the inputs into a slice so we can sort them.
4141
inputList := make([]*pendingInput, 0, len(c.inputs))
@@ -138,7 +138,7 @@ type SimpleAggregator struct {
138138
// MaxInputsPerTx specifies the default maximum number of inputs allowed
139139
// in a single sweep tx. If more need to be swept, multiple txes are
140140
// created and published.
141-
MaxInputsPerTx int
141+
MaxInputsPerTx uint32
142142

143143
// FeeRateBucketSize is the default size of fee rate buckets we'll use
144144
// when clustering inputs into buckets with similar fee rates within
@@ -158,7 +158,7 @@ var _ UtxoAggregator = (*SimpleAggregator)(nil)
158158

159159
// NewSimpleUtxoAggregator creates a new instance of a SimpleAggregator.
160160
func NewSimpleUtxoAggregator(estimator chainfee.Estimator,
161-
max chainfee.SatPerKWeight, maxTx int) *SimpleAggregator {
161+
max chainfee.SatPerKWeight, maxTx uint32) *SimpleAggregator {
162162

163163
return &SimpleAggregator{
164164
FeeEstimator: estimator,

sweep/sweeper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ type UtxoSweeperConfig struct {
335335
// MaxInputsPerTx specifies the default maximum number of inputs allowed
336336
// in a single sweep tx. If more need to be swept, multiple txes are
337337
// created and published.
338-
MaxInputsPerTx int
338+
MaxInputsPerTx uint32
339339

340340
// MaxSweepAttempts specifies the maximum number of times an input is
341341
// included in a publish attempt before giving up and returning an error

sweep/sweeper_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030

3131
testMaxSweepAttempts = 3
3232

33-
testMaxInputsPerTx = 3
33+
testMaxInputsPerTx = uint32(3)
3434

3535
defaultFeePref = Params{Fee: FeeEstimateInfo{ConfTarget: 1}}
3636
)

sweep/tx_input_set.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ type txInputSet struct {
139139

140140
// maxInputs is the maximum number of inputs that will be accepted in
141141
// the set.
142-
maxInputs int
142+
maxInputs uint32
143143
}
144144

145145
// Compile-time constraint to ensure txInputSet implements InputSet.
146146
var _ InputSet = (*txInputSet)(nil)
147147

148148
// newTxInputSet constructs a new, empty input set.
149149
func newTxInputSet(feePerKW, maxFeeRate chainfee.SatPerKWeight,
150-
maxInputs int) *txInputSet {
150+
maxInputs uint32) *txInputSet {
151151

152152
state := txInputSetState{
153153
feeRate: feePerKW,
@@ -215,7 +215,7 @@ func (t *txInputSet) addToState(inp input.Input,
215215
// Stop if max inputs is reached. Do not count additional wallet inputs,
216216
// because we don't know in advance how many we may need.
217217
if constraints != constraintsWallet &&
218-
len(t.inputs) >= t.maxInputs {
218+
uint32(len(t.inputs)) >= t.maxInputs {
219219

220220
return nil
221221
}

sweep/txgenerator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
// DefaultMaxInputsPerTx specifies the default maximum number of inputs
2020
// allowed in a single sweep tx. If more need to be swept, multiple txes
2121
// are created and published.
22-
DefaultMaxInputsPerTx = 100
22+
DefaultMaxInputsPerTx = uint32(100)
2323

2424
// ErrLocktimeConflict is returned when inputs with different
2525
// transaction nLockTime values are included in the same transaction.

0 commit comments

Comments
 (0)