Skip to content

Commit

Permalink
Merge pull request #1764 from cfromknecht/isolate-fwdpkg-to-live-links
Browse files Browse the repository at this point in the history
htlcswitch/link: only resovle+gc fwdpkgs for live channels
  • Loading branch information
Roasbeef committed Aug 25, 2018
2 parents c41ea48 + 211a029 commit 5cf911a
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions htlcswitch/link.go
Expand Up @@ -847,18 +847,23 @@ 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
if err := l.resolveFwdPkgs(); err != nil { // only attempt to resolve packages if our short chan id indicates that
l.fail(LinkFailureError{code: ErrInternalError}, // the channel is not pending, otherwise we should have no htlcs to
"unable to resolve fwd pkgs: %v", err) // reforward.
return if l.ShortChanID() != sourceHop {
} if err := l.resolveFwdPkgs(); err != nil {
l.fail(LinkFailureError{code: ErrInternalError},
"unable to resolve fwd pkgs: %v", err)
return
}


// With our link's in-memory state fully reconstructed, spawn a // With our link's in-memory state fully reconstructed, spawn a
// goroutine to manage the reclamation of disk space occupied by // goroutine to manage the reclamation of disk space occupied by
// completed forwarding packages. // completed forwarding packages.
l.wg.Add(1) l.wg.Add(1)
go l.fwdPkgGarbager() go l.fwdPkgGarbager()
}


out: out:
for { for {
Expand Down Expand Up @@ -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
} }


Expand Down

0 comments on commit 5cf911a

Please sign in to comment.