Merge pull request #1764 from cfromknecht/isolate-fwdpkg-to-live-links

htlcswitch/link: only resovle+gc fwdpkgs for live channels
This commit is contained in:
Olaoluwa Osuntokun 2018-08-24 17:42:44 -07:00 committed by GitHub
commit 5cf911a762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -847,7 +847,11 @@ func (l *channelLink) htlcManager() {
// After cleaning up any memory pertaining to incoming packets, we now // After cleaning up any memory pertaining to incoming packets, we now
// replay our forwarding packages to handle any htlcs that can be // replay our forwarding packages to handle any htlcs that can be
// processed locally, or need to be forwarded out to the switch. // processed locally, or need to be forwarded out to the switch. We will
// only attempt to resolve packages if our short chan id indicates that
// the channel is not pending, otherwise we should have no htlcs to
// reforward.
if l.ShortChanID() != sourceHop {
if err := l.resolveFwdPkgs(); err != nil { if err := l.resolveFwdPkgs(); err != nil {
l.fail(LinkFailureError{code: ErrInternalError}, l.fail(LinkFailureError{code: ErrInternalError},
"unable to resolve fwd pkgs: %v", err) "unable to resolve fwd pkgs: %v", err)
@ -859,6 +863,7 @@ func (l *channelLink) htlcManager() {
// completed forwarding packages. // completed forwarding packages.
l.wg.Add(1) l.wg.Add(1)
go l.fwdPkgGarbager() go l.fwdPkgGarbager()
}
out: out:
for { for {
@ -1770,6 +1775,11 @@ func (l *channelLink) UpdateShortChanID() (lnwire.ShortChannelID, error) {
} }
}() }()
// Now that the short channel ID has been properly updated, we can begin
// garbage collecting any forwarding packages we create.
l.wg.Add(1)
go l.fwdPkgGarbager()
return sid, nil return sid, nil
} }