lnd: skip ErrEdgeNotFound when iterating channels

We now skip another error when iterating the channels for our persistent
peers to unblock connecting to other peers.
This commit is contained in:
yyforyongyu
2025-03-26 00:15:23 +08:00
parent dd8f2888a0
commit 799ce9752a

View File

@@ -3547,8 +3547,9 @@ func (s *server) establishPersistentConnections() error {
// the reconnection port to the default peer port.
linkNodes, err := s.chanStateDB.LinkNodeDB().FetchAllLinkNodes()
if err != nil && err != channeldb.ErrLinkNodesNotFound {
return err
return fmt.Errorf("failed to fetch all link nodes: %w", err)
}
for _, node := range linkNodes {
pubStr := string(node.IdentityPub.SerializeCompressed())
nodeAddrs := &nodeAddresses{
@@ -3563,7 +3564,7 @@ func (s *server) establishPersistentConnections() error {
// that have been added via NodeAnnouncement messages.
sourceNode, err := s.graphDB.SourceNode()
if err != nil {
return err
return fmt.Errorf("failed to fetch source node: %w", err)
}
// TODO(roasbeef): instead iterate over link nodes and query graph for
@@ -3649,8 +3650,15 @@ func (s *server) establishPersistentConnections() error {
nodeAddrsMap[pubStr] = n
return nil
})
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
return err
if err != nil {
srvrLog.Errorf("Failed to iterate channels for node %x",
sourceNode.PubKeyBytes)
if !errors.Is(err, graphdb.ErrGraphNoEdgesFound) &&
!errors.Is(err, graphdb.ErrEdgeNotFound) {
return err
}
}
srvrLog.Debugf("Establishing %v persistent connections on start",