mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
htlcswitch/switch: ignore pending/local responses on reforward
This commit is contained in:
parent
81b4af2ec8
commit
6a8507cfb5
@ -1628,15 +1628,35 @@ func (s *Switch) Start() error {
|
|||||||
// forwarding packages and reforwards any Settle or Fail HTLCs found. This is
|
// forwarding packages and reforwards any Settle or Fail HTLCs found. This is
|
||||||
// used to resurrect the switch's mailboxes after a restart.
|
// used to resurrect the switch's mailboxes after a restart.
|
||||||
func (s *Switch) reforwardResponses() error {
|
func (s *Switch) reforwardResponses() error {
|
||||||
activeChannels, err := s.cfg.DB.FetchAllOpenChannels()
|
openChannels, err := s.cfg.DB.FetchAllOpenChannels()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, activeChannel := range activeChannels {
|
for _, openChannel := range openChannels {
|
||||||
shortChanID := activeChannel.ShortChanID()
|
shortChanID := openChannel.ShortChanID()
|
||||||
|
|
||||||
|
// Locally-initiated payments never need reforwarding.
|
||||||
|
if shortChanID == sourceHop {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the channel is pending, it should have no forwarding
|
||||||
|
// packages, and nothing to reforward.
|
||||||
|
if openChannel.IsPending {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Channels in open or waiting-close may still have responses in
|
||||||
|
// their forwarding packages. We will continue to reattempt
|
||||||
|
// forwarding on startup until the channel is fully-closed.
|
||||||
|
//
|
||||||
|
// Load this channel's forwarding packages, and deliver them to
|
||||||
|
// the switch.
|
||||||
fwdPkgs, err := s.loadChannelFwdPkgs(shortChanID)
|
fwdPkgs, err := s.loadChannelFwdPkgs(shortChanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Errorf("unable to load forwarding "+
|
||||||
|
"packages for %v: %v", shortChanID, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user