From cfdf3f3ab55d42107710d2e4a92dd6ede555a186 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 26 Sep 2016 10:39:47 -0700 Subject: [PATCH] peer: send any pending HTLC settles when the commit timer ticks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- peer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index 9c31074c..48c449be 100644 --- a/peer.go +++ b/peer.go @@ -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 }