Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/release-notes/release-notes-0.20.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

# Bug Fixes

- [Fixed premature wallet
rescanning](https://github.com/lightningnetwork/lnd/pull/10280) that occurred
when a wallet was created during header sync. This issue primarily affected
neutrino chain backends. The fix ensures headers are fully synced before
starting the chain notifier backend.

- Fixed potential update inconsistencies in node announcements [by creating
a shallow copy before modifications](
https://github.com/lightningnetwork/lnd/pull/9815). This ensures the original
Expand Down
52 changes: 12 additions & 40 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,17 +733,6 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
quit: make(chan struct{}),
}

// Start the low-level services once they are initialized.
//
// TODO(yy): break the server startup into four steps,
// 1. init the low-level services.
// 2. start the low-level services.
// 3. init the high-level services.
// 4. start the high-level services.
Comment on lines -738 to -742
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be a planned future improvement. If these code changes are approved and merged as-is, it would be beneficial creating a tracking issue for this TODO(s) probably by the assignee to ensure we don't lose track of it

if err := s.startLowLevelServices(); err != nil {
return nil, err
}

currentHash, currentHeight, err := s.cc.ChainIO.GetBestBlock()
if err != nil {
return nil, err
Expand Down Expand Up @@ -2125,41 +2114,12 @@ func (c cleaner) run() {
}
}

// startLowLevelServices starts the low-level services of the server. These
// services must be started successfully before running the main server. The
// services are,
// 1. the chain notifier.
//
// TODO(yy): identify and add more low-level services here.
func (s *server) startLowLevelServices() error {
var startErr error

cleanup := cleaner{}

cleanup = cleanup.add(s.cc.ChainNotifier.Stop)
if err := s.cc.ChainNotifier.Start(); err != nil {
startErr = err
}

if startErr != nil {
cleanup.run()
}

return startErr
}

// Start starts the main daemon server, all requested listeners, and any helper
// goroutines.
// NOTE: This function is safe for concurrent access.
//
//nolint:funlen
func (s *server) Start(ctx context.Context) error {
// Get the current blockbeat.
beat, err := s.getStartingBeat()
if err != nil {
return err
}

var startErr error

// If one sub system fails to start, the following code ensures that the
Expand Down Expand Up @@ -2213,6 +2173,12 @@ func (s *server) Start(ctx context.Context) error {
return
}

cleanup = cleanup.add(s.cc.ChainNotifier.Stop)
if err := s.cc.ChainNotifier.Start(); err != nil {
startErr = err
return
}

cleanup = cleanup.add(s.cc.BestBlockTracker.Stop)
if err := s.cc.BestBlockTracker.Start(); err != nil {
startErr = err
Expand Down Expand Up @@ -2247,6 +2213,12 @@ func (s *server) Start(ctx context.Context) error {
}
}

beat, err := s.getStartingBeat()
if err != nil {
startErr = err
return
}

cleanup = cleanup.add(s.txPublisher.Stop)
if err := s.txPublisher.Start(beat); err != nil {
startErr = err
Expand Down
Loading