htlcswitch: stop batch timer if there are no updates

This commit is contained in:
Joost Jager 2019-09-24 11:49:32 +02:00
parent 03b32d046a
commit 2482d84d7d
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -1023,11 +1023,14 @@ out:
break out break out
} }
// If the previous event resulted in a non-empty // If the previous event resulted in a non-empty batch, resume
// batch, reinstate the batch ticker so that it can be // the batch ticker so that it can be cleared. Otherwise pause
// cleared. // the ticker to prevent waking up the htlcManager while the
// batch is empty.
if l.batchCounter > 0 { if l.batchCounter > 0 {
l.cfg.BatchTicker.Resume() l.cfg.BatchTicker.Resume()
} else {
l.cfg.BatchTicker.Pause()
} }
select { select {
@ -1109,19 +1112,10 @@ out:
} }
case <-l.cfg.BatchTicker.Ticks(): case <-l.cfg.BatchTicker.Ticks():
// If the current batch is empty, then we have no work // Attempt to extend the remote commitment chain
// here. We also disable the batch ticker from waking up // including all the currently pending entries. If the
// the htlcManager while the batch is empty. // send was unsuccessful, then abandon the update,
if l.batchCounter == 0 { // waiting for the revocation window to open up.
l.cfg.BatchTicker.Pause()
continue
}
// Otherwise, attempt to extend the remote commitment
// chain including all the currently pending entries.
// If the send was unsuccessful, then abandon the
// update, waiting for the revocation window to open
// up.
if err := l.updateCommitTx(); err != nil { if err := l.updateCommitTx(); err != nil {
l.fail(LinkFailureError{code: ErrInternalError}, l.fail(LinkFailureError{code: ErrInternalError},
"unable to update commitment: %v", err) "unable to update commitment: %v", err)