2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-09 19:10:47 +00:00

sweepbatcher: log the reason of acceptance failure

Add Info log message in cases when addSweep returns accept=false and err=nil.
This commit is contained in:
Boris Nagaev 2024-08-26 20:53:29 -03:00
parent f21a21ee41
commit 7780aca492
No known key found for this signature in database

View File

@ -438,6 +438,8 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
// If the provided sweep is nil, we can't proceed with any checks, so
// we just return early.
if sweep == nil {
b.log.Infof("the sweep is nil")
return false, nil
}
@ -471,6 +473,9 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
// the batch, do not add another sweep to prevent the tx from becoming
// non-standard.
if len(b.sweeps) >= MaxSweepsPerBatch {
b.log.Infof("the batch has already too many sweeps (%d >= %d)",
len(b.sweeps), MaxSweepsPerBatch)
return false, nil
}
@ -478,6 +483,8 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
// arrive here after the batch got closed because of a spend. In this
// case we cannot add the sweep to this batch.
if b.state != Open {
b.log.Infof("the batch state (%v) is not open", b.state)
return false, nil
}
@ -485,7 +492,17 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
// address, or the incoming sweep is spending to non-wallet address,
// we cannot add this sweep to the batch.
for _, s := range b.sweeps {
if s.isExternalAddr || sweep.isExternalAddr {
if s.isExternalAddr {
b.log.Infof("the batch already has a sweep (%x) with "+
"an external address", s.swapHash[:6])
return false, nil
}
if sweep.isExternalAddr {
b.log.Infof("the batch is not empty and new sweep (%x)"+
" has an external address", sweep.swapHash[:6])
return false, nil
}
}
@ -498,6 +515,11 @@ func (b *batch) addSweep(ctx context.Context, sweep *sweep) (bool, error) {
int32(math.Abs(float64(sweep.timeout - s.timeout)))
if timeoutDistance > b.cfg.maxTimeoutDistance {
b.log.Infof("too long timeout distance between the "+
"batch and sweep %x: %d > %d",
sweep.swapHash[:6], timeoutDistance,
b.cfg.maxTimeoutDistance)
return false, nil
}
}