Merge pull request #10280 from mohamedawnallah/optimize-neutrino-rescan
rpcserver: resolve root cause of premature wallet rescanning
This commit is contained in:
2 files changed
+18
-40
No files matched your search
@@ -20,6 +20,12 @@
|
|||||||
|
|
||||||
# Bug Fixes
|
# 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
|
- Fixed potential update inconsistencies in node announcements [by creating
|
||||||
a shallow copy before modifications](
|
a shallow copy before modifications](
|
||||||
https://github.com/lightningnetwork/lnd/pull/9815). This ensures the original
|
https://github.com/lightningnetwork/lnd/pull/9815). This ensures the original
|
||||||
|
|||||||
@@ -733,17 +733,6 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
|
|||||||
quit: make(chan struct{}),
|
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.
|
|
||||||
if err := s.startLowLevelServices(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
currentHash, currentHeight, err := s.cc.ChainIO.GetBestBlock()
|
currentHash, currentHeight, err := s.cc.ChainIO.GetBestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -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
|
// Start starts the main daemon server, all requested listeners, and any helper
|
||||||
// goroutines.
|
// goroutines.
|
||||||
// NOTE: This function is safe for concurrent access.
|
// NOTE: This function is safe for concurrent access.
|
||||||
//
|
//
|
||||||
//nolint:funlen
|
//nolint:funlen
|
||||||
func (s *server) Start(ctx context.Context) error {
|
func (s *server) Start(ctx context.Context) error {
|
||||||
// Get the current blockbeat.
|
|
||||||
beat, err := s.getStartingBeat()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var startErr error
|
var startErr error
|
||||||
|
|
||||||
// If one sub system fails to start, the following code ensures that the
|
// If one sub system fails to start, the following code ensures that the
|
||||||
@@ -2213,6 +2173,12 @@ func (s *server) Start(ctx context.Context) error {
|
|||||||
return
|
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)
|
cleanup = cleanup.add(s.cc.BestBlockTracker.Stop)
|
||||||
if err := s.cc.BestBlockTracker.Start(); err != nil {
|
if err := s.cc.BestBlockTracker.Start(); err != nil {
|
||||||
startErr = err
|
startErr = err
|
||||||
@@ -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)
|
cleanup = cleanup.add(s.txPublisher.Stop)
|
||||||
if err := s.txPublisher.Start(beat); err != nil {
|
if err := s.txPublisher.Start(beat); err != nil {
|
||||||
startErr = err
|
startErr = err
|
||||||
|
|||||||
Reference in new issue
Block a user