Skip to content

Commit 4258b95

Browse files
committed
sweepbatcher: fix too long lines
1 parent 0b2c177 commit 4258b95

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

sweepbatcher/log.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func init() {
1717
UseLogger(build.NewSubLogger("SWEEP", nil))
1818
}
1919

20-
// batchPrefixLogger returns a logger that prefixes all log messages with the ID.
20+
// batchPrefixLogger returns a logger that prefixes all log messages with
21+
// the ID.
2122
func batchPrefixLogger(batchID string) btclog.Logger {
2223
return build.NewPrefixLog(fmt.Sprintf("[Batch %s]", batchID), log)
2324
}

sweepbatcher/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ func NewSQLStore(db BaseDB, network *chaincfg.Params) *SQLStore {
8282

8383
// FetchUnconfirmedSweepBatches fetches all the batches from the database that
8484
// are not in a confirmed state.
85-
func (s *SQLStore) FetchUnconfirmedSweepBatches(ctx context.Context) ([]*dbBatch,
86-
error) {
85+
func (s *SQLStore) FetchUnconfirmedSweepBatches(ctx context.Context) (
86+
[]*dbBatch, error) {
8787

8888
var batches []*dbBatch
8989

sweepbatcher/sweep_batch.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) {
592592
batchTx.LockTime = uint32(b.currentHeight)
593593

594594
var (
595-
batchAmt btcutil.Amount
596-
prevOuts = make([]*wire.TxOut, 0, len(b.sweeps))
597-
signDescs = make([]*lndclient.SignDescriptor, 0, len(b.sweeps))
595+
batchAmt btcutil.Amount
596+
prevOuts = make([]*wire.TxOut, 0, len(b.sweeps))
597+
signDescs = make(
598+
[]*lndclient.SignDescriptor, 0, len(b.sweeps),
599+
)
598600
sweeps = make([]sweep, 0, len(b.sweeps))
599601
fee btcutil.Amount
600602
inputCounter int

sweepbatcher/sweep_batcher.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ func (b *Batcher) handleSweep(ctx context.Context, sweep *sweep,
328328

329329
if !accepted {
330330
return fmt.Errorf("existing sweep %x was not "+
331-
"accepted by batch %d", sweep.swapHash[:6],
332-
batch.id)
331+
"accepted by batch %d",
332+
sweep.swapHash[:6], batch.id)
333333
}
334334

335335
// The sweep was updated in the batch, our job is done.
@@ -464,6 +464,8 @@ func (b *Batcher) spinUpBatchFromDB(ctx context.Context, batch *batch) error {
464464
FeeRate: batch.rbfCache.FeeRate,
465465
}
466466

467+
logger := batchPrefixLogger(fmt.Sprintf("%d", batch.id))
468+
467469
batchKit := batchKit{
468470
id: batch.id,
469471
batchTxid: batch.batchTxid,
@@ -480,7 +482,7 @@ func (b *Batcher) spinUpBatchFromDB(ctx context.Context, batch *batch) error {
480482
verifySchnorrSig: b.VerifySchnorrSig,
481483
purger: b.AddSweep,
482484
store: b.store,
483-
log: batchPrefixLogger(fmt.Sprintf("%d", batch.id)),
485+
log: logger,
484486
quit: b.quit,
485487
}
486488

@@ -601,15 +603,17 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
601603
totalSwept,
602604
)
603605

606+
onChainFeePortion := getFeePortionPaidBySweep(
607+
spendTx, feePortionPerSweep,
608+
roundingDifference, sweep,
609+
)
610+
604611
// Notify the requester of the spend
605612
// with the spend details, including the fee
606613
// portion for this particular sweep.
607614
spendDetail := &SpendDetail{
608-
Tx: spendTx,
609-
OnChainFeePortion: getFeePortionPaidBySweep( // nolint:lll
610-
spendTx, feePortionPerSweep,
611-
roundingDifference, sweep,
612-
),
615+
Tx: spendTx,
616+
OnChainFeePortion: onChainFeePortion,
613617
}
614618

615619
select {

sweepbatcher/sweep_batcher_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ func TestSweepBatcherBatchCreation(t *testing.T) {
182182
<-lnd.RegisterSpendChannel
183183

184184
require.Eventually(t, func() bool {
185-
// Verify that each batch has the correct number of sweeps in it.
185+
// Verify that each batch has the correct number of sweeps
186+
// in it.
186187
for _, batch := range batcher.batches {
187188
switch batch.primarySweepID {
188189
case sweepReq1.SwapHash:
@@ -481,7 +482,9 @@ func TestSweepBatcherSweepReentry(t *testing.T) {
481482
},
482483
TxOut: []*wire.TxOut{
483484
{
484-
Value: int64(sweepReq1.Value.ToUnit(btcutil.AmountSatoshi)),
485+
Value: int64(sweepReq1.Value.ToUnit(
486+
btcutil.AmountSatoshi,
487+
)),
485488
PkScript: []byte{3, 2, 1},
486489
},
487490
},
@@ -683,7 +686,8 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) {
683686
<-lnd.RegisterSpendChannel
684687

685688
require.Eventually(t, func() bool {
686-
// Verify that each batch has the correct number of sweeps in it.
689+
// Verify that each batch has the correct number of sweeps
690+
// in it.
687691
for _, batch := range batcher.batches {
688692
switch batch.primarySweepID {
689693
case sweepReq1.SwapHash:

0 commit comments

Comments
 (0)