peer: send any pending HTLC settles when the commit timer ticks

This commit adds an additional clause to the update of the current
commitment state each time the commitTimer ticks. We now additional
check to see if we have any active HTLC’s to settle, triggering a state
update if so.

This case is needed due to the possibility of desynchronization across
commitment transactions. As an example if any HTLC adds are sent after
the remote node receives our ack-sig, then they may remain uncommitted
within our local commitment chain. The addition of this check solves
the issue by ensuring convergence towards a symmetric commitment state.
This commit is contained in:
Olaoluwa Osuntokun 2016-09-26 10:39:47 -07:00
parent f1d0b75b9d
commit cfdf3f3ab5
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -56,6 +56,7 @@ type chanSnapshotReq struct {
// for managing any channel state related to this peer. To do so, it has several
// helper goroutines to handle events such as HTLC timeouts, new funding
// workflow, and detecting an uncooperative closure of any active channels.
// TODO(roasbeef): proper reconnection logic
type peer struct {
// MUST be used atomically.
started int32
@ -975,7 +976,8 @@ out:
// pending updates we need to commit. If so, then send
// an update incrementing the unacked counter is
// succesful.
if !state.channel.PendingUpdates() {
if !state.channel.PendingUpdates() &&
len(state.htlcsToSettle) == 0 {
continue
}