Skip to content

Commit

Permalink
sweep: change MaxInputsPerTx from int to uint32
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Mar 27, 2024
1 parent d3d21bb commit 7bb12c5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions sweep/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sweep/sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sweep/sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (

testMaxSweepAttempts = 3

testMaxInputsPerTx = 3
testMaxInputsPerTx = uint32(3)

defaultFeePref = Params{Fee: FeeEstimateInfo{ConfTarget: 1}}
)
Expand Down
6 changes: 3 additions & 3 deletions sweep/tx_input_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ 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.
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,
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion sweep/txgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7bb12c5

Please sign in to comment.