@@ -438,6 +438,8 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
438438 // If the provided sweep is nil, we can't proceed with any checks, so
439439 // we just return early.
440440 if sweep == nil {
441+ b .log .Infof ("the sweep is nil" )
442+
441443 return false , nil
442444 }
443445
@@ -471,21 +473,36 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
471473 // the batch, do not add another sweep to prevent the tx from becoming
472474 // non-standard.
473475 if len (b .sweeps ) >= MaxSweepsPerBatch {
476+ b .log .Infof ("the batch has already too many sweeps (%d >= %d)" ,
477+ len (b .sweeps ), MaxSweepsPerBatch )
478+
474479 return false , nil
475480 }
476481
477482 // Since all the actions of the batch happen sequentially, we could
478483 // arrive here after the batch got closed because of a spend. In this
479484 // case we cannot add the sweep to this batch.
480485 if b .state != Open {
486+ b .log .Infof ("the batch state (%v) is not open" , b .state )
487+
481488 return false , nil
482489 }
483490
484491 // If this batch contains a single sweep that spends to a non-wallet
485492 // address, or the incoming sweep is spending to non-wallet address,
486493 // we cannot add this sweep to the batch.
487494 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+
489506 return false , nil
490507 }
491508 }
@@ -498,6 +515,11 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
498515 int32 (math .Abs (float64 (sweep .timeout - s .timeout )))
499516
500517 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+
501523 return false , nil
502524 }
503525 }
0 commit comments