@@ -438,6 +438,8 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
438
438
// If the provided sweep is nil, we can't proceed with any checks, so
439
439
// we just return early.
440
440
if sweep == nil {
441
+ b .log .Infof ("the sweep is nil" )
442
+
441
443
return false , nil
442
444
}
443
445
@@ -471,21 +473,36 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
471
473
// the batch, do not add another sweep to prevent the tx from becoming
472
474
// non-standard.
473
475
if len (b .sweeps ) >= MaxSweepsPerBatch {
476
+ b .log .Infof ("the batch has already too many sweeps (%d >= %d)" ,
477
+ len (b .sweeps ), MaxSweepsPerBatch )
478
+
474
479
return false , nil
475
480
}
476
481
477
482
// Since all the actions of the batch happen sequentially, we could
478
483
// arrive here after the batch got closed because of a spend. In this
479
484
// case we cannot add the sweep to this batch.
480
485
if b .state != Open {
486
+ b .log .Infof ("the batch state (%v) is not open" , b .state )
487
+
481
488
return false , nil
482
489
}
483
490
484
491
// If this batch contains a single sweep that spends to a non-wallet
485
492
// address, or the incoming sweep is spending to non-wallet address,
486
493
// we cannot add this sweep to the batch.
487
494
for _ , s := range b .sweeps {
488
- if s .isExternalAddr || sweep .isExternalAddr {
495
+ if s .isExternalAddr {
496
+ b .log .Infof ("the batch already has a sweep (%x) with " +
497
+ "an external address" , s .swapHash [:6 ])
498
+
499
+ return false , nil
500
+ }
501
+
502
+ if sweep .isExternalAddr {
503
+ b .log .Infof ("the batch is not empty and new sweep (%x)" +
504
+ " has an external address" , sweep .swapHash [:6 ])
505
+
489
506
return false , nil
490
507
}
491
508
}
@@ -498,6 +515,11 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
498
515
int32 (math .Abs (float64 (sweep .timeout - s .timeout )))
499
516
500
517
if timeoutDistance > b .cfg .maxTimeoutDistance {
518
+ b .log .Infof ("too long timeout distance between the " +
519
+ "batch and sweep %x: %d > %d" ,
520
+ sweep .swapHash [:6 ], timeoutDistance ,
521
+ b .cfg .maxTimeoutDistance )
522
+
501
523
return false , nil
502
524
}
503
525
}
0 commit comments