From 710c2f5dac3ad37006752583cb6a02d6d6471e44 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 2 Oct 2017 22:09:40 -0700 Subject: [PATCH] htlcswitch: if unable to add half in channel link, properly increment bandwidth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes an existing bug, wherein if we failed to account for the fact that if we we’re unable to add an HTLC for any reason other than an overflown commitment transaction, then we wouldn’t properly re-add the available bandwidth of the offending HTLC. --- htlcswitch/link.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 516b8243..9707b305 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -587,6 +587,10 @@ func (l *channelLink) handleDownStreamPkt(pkt *htlcPacket, isReProcess bool) { isObfuscated, ) + atomic.AddUint64(&l.availableBandwidth, uint64(htlc.Amount)) + + // TODO(roasbeef): need to identify if sent + // from switch so don't need to obfuscate go l.cfg.Switch.forward(failPkt) log.Infof("Unable to handle downstream add HTLC: %v", err) return