etcd: decouple embedded etcd instance startup

This refactor changes how we instantiate the etcd based Backend to allow
separate initialization and startup for the embedded instance.
This commit is contained in:
Andras Banki-Horvath
2021-02-09 17:44:43 +01:00
parent 6757e14998
commit 9992e5c0b5
5 changed files with 46 additions and 47 deletions

7
lnd.go
View File

@@ -234,6 +234,13 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
ctx, cancel := context.WithCancel(ctx)
defer cancel()
// Run configuration dependent DB pre-initialization. Note that this
// needs to be done early and once during the startup process, before
// any DB access.
if err := cfg.DB.Init(ctx, cfg.localDatabaseDir()); err != nil {
return err
}
localChanDB, remoteChanDB, cleanUp, err := initializeDatabases(ctx, cfg)
switch {
case err == channeldb.ErrDryRunMigrationOK: