loopd: Run migration if boltdb exists

This commit is contained in:
sputn1ck 2023-05-19 15:09:08 +02:00
parent 69b4df0d9b
commit a2abcd07d8
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4
2 changed files with 108 additions and 4 deletions

View file

@ -370,8 +370,24 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
}
}
// Both the client RPC server and and the swap server client should
// stop on main context cancel. So we create it early and pass it down.
d.mainCtx, d.mainCtxCancel = context.WithCancel(context.Background())
log.Infof("Swap server address: %v", d.cfg.Server.Host)
// Check if we need to migrate the database.
if needSqlMigration(d.cfg) {
log.Infof("Boltdb found, running migration")
err := migrateBoltdb(d.mainCtx, d.cfg)
if err != nil {
return fmt.Errorf("unable to migrate boltdb: %v", err)
}
log.Infof("Successfully migrated boltdb")
}
// Create an instance of the loop client library.
swapclient, clientCleanup, err := getClient(d.cfg, &d.lnd.LndServices)
if err != nil {
@ -379,10 +395,6 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
}
d.clientCleanup = clientCleanup
// Both the client RPC server and and the swap server client should
// stop on main context cancel. So we create it early and pass it down.
d.mainCtx, d.mainCtxCancel = context.WithCancel(context.Background())
// Add our debug permissions to our main set of required permissions
// if compiled in.
for endpoint, perm := range debugRequiredPermissions {