mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-30 15:02:29 +02:00
Merge pull request #9643 from yyforyongyu/fix-startup
lnd: make sure startup flow is not aborted
This commit is contained in:
commit
f48e5098b1
@ -107,6 +107,10 @@
|
||||
keysend payment would not fail properly and only resolve after restart. Now
|
||||
keysend payment validation is stricter.
|
||||
|
||||
* [Make sure](https://github.com/lightningnetwork/lnd/pull/9643) the startup
|
||||
process of the node won't be interrupted if a non-fatal error is returned from
|
||||
the subsystems.
|
||||
|
||||
# New Features
|
||||
|
||||
* Add support for [archiving channel backup](https://github.com/lightningnetwork/lnd/pull/9232)
|
||||
|
32
server.go
32
server.go
@ -2195,7 +2195,7 @@ func (c cleaner) add(cleanup func() error) cleaner {
|
||||
func (c cleaner) run() {
|
||||
for i := len(c) - 1; i >= 0; i-- {
|
||||
if err := c[i](); err != nil {
|
||||
srvrLog.Infof("Cleanup failed: %v", err)
|
||||
srvrLog.Errorf("Cleanup failed: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2498,7 +2498,11 @@ func (s *server) Start() error {
|
||||
// brontide.NewListener() is called in newServer. This means
|
||||
// that we are actually listening and partially accepting
|
||||
// inbound connections even before the connMgr starts.
|
||||
//
|
||||
// TODO(yy): move the log into the connMgr's `Start` method.
|
||||
srvrLog.Info("connMgr starting...")
|
||||
s.connMgr.Start()
|
||||
srvrLog.Debug("connMgr started")
|
||||
|
||||
// If peers are specified as a config option, we'll add those
|
||||
// peers first.
|
||||
@ -2540,6 +2544,9 @@ func (s *server) Start() error {
|
||||
// Subscribe to NodeAnnouncements that advertise new addresses
|
||||
// our persistent peers.
|
||||
if err := s.updatePersistentPeerAddrs(); err != nil {
|
||||
srvrLog.Errorf("Failed to update persistent peer "+
|
||||
"addr: %v", err)
|
||||
|
||||
startErr = err
|
||||
return
|
||||
}
|
||||
@ -2551,12 +2558,15 @@ func (s *server) Start() error {
|
||||
// to ensure we don't reconnect to any nodes we no longer have
|
||||
// open channels with.
|
||||
if err := s.chanStateDB.PruneLinkNodes(); err != nil {
|
||||
srvrLog.Errorf("Failed to prune link nodes: %v", err)
|
||||
|
||||
startErr = err
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.establishPersistentConnections(); err != nil {
|
||||
startErr = err
|
||||
return
|
||||
srvrLog.Errorf("Failed to establish persistent "+
|
||||
"connections: %v", err)
|
||||
}
|
||||
|
||||
// setSeedList is a helper function that turns multiple DNS seed
|
||||
@ -3535,8 +3545,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{
|
||||
@ -3551,7 +3562,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
|
||||
@ -3637,8 +3648,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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user