From 5cdc7550b52c828a27047a6b5056e47462770f72 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 12 Apr 2018 12:53:33 +0200 Subject: [PATCH] htlcswitch: use FetchAllOpenChannels This commit changes from using FetchAllChannels to FetchAllOpenChannels, making the check for whether a channel is pending unnecessary. --- htlcswitch/circuit_map.go | 6 +----- htlcswitch/switch.go | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/htlcswitch/circuit_map.go b/htlcswitch/circuit_map.go index e5076544..844a9316 100644 --- a/htlcswitch/circuit_map.go +++ b/htlcswitch/circuit_map.go @@ -350,16 +350,12 @@ func (cm *circuitMap) decodeCircuit(v []byte) (*PaymentCircuit, error) { // channels. Therefore, it must be called before any links are created to avoid // interfering with normal operation. func (cm *circuitMap) trimAllOpenCircuits() error { - activeChannels, err := cm.cfg.DB.FetchAllChannels() + activeChannels, err := cm.cfg.DB.FetchAllOpenChannels() if err != nil { return err } for _, activeChannel := range activeChannels { - if activeChannel.IsPending { - continue - } - chanID := activeChannel.ShortChanID start := activeChannel.LocalCommitment.LocalHtlcIndex if err := cm.TrimOpenCircuits(chanID, start); err != nil { diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 11b4efed..cf1750c8 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -1513,16 +1513,12 @@ func (s *Switch) Start() error { // forwarding packages and reforwards any Settle or Fail HTLCs found. This is // used to resurrect the switch's mailboxes after a restart. func (s *Switch) reforwardResponses() error { - activeChannels, err := s.cfg.DB.FetchAllChannels() + activeChannels, err := s.cfg.DB.FetchAllOpenChannels() if err != nil { return err } for _, activeChannel := range activeChannels { - if activeChannel.IsPending { - continue - } - shortChanID := activeChannel.ShortChanID fwdPkgs, err := s.loadChannelFwdPkgs(shortChanID) if err != nil {