mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
Merge pull request #8831 from bhandras/sql-invoice-migration
invoices: migrate KV invoices to native SQL for users of KV SQL backends
This commit is contained in:
21
lncfg/db.go
21
lncfg/db.go
@@ -87,6 +87,8 @@ type DB struct {
|
||||
|
||||
UseNativeSQL bool `long:"use-native-sql" description:"Use native SQL for tables that already support it."`
|
||||
|
||||
SkipSQLInvoiceMigration bool `long:"skip-sql-invoice-migration" description:"Do not migrate invoices stored in our key-value database to native SQL."`
|
||||
|
||||
NoGraphCache bool `long:"no-graph-cache" description:"Don't use the in-memory graph cache for path finding. Much slower but uses less RAM. Can only be used with a bolt database backend."`
|
||||
|
||||
PruneRevocation bool `long:"prune-revocation" description:"Run the optional migration that prunes the revocation logs to save disk space."`
|
||||
@@ -115,7 +117,8 @@ func DefaultDB() *DB {
|
||||
MaxConnections: defaultSqliteMaxConnections,
|
||||
BusyTimeout: defaultSqliteBusyTimeout,
|
||||
},
|
||||
UseNativeSQL: false,
|
||||
UseNativeSQL: false,
|
||||
SkipSQLInvoiceMigration: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,10 +234,10 @@ type DatabaseBackends struct {
|
||||
// the underlying wallet database from.
|
||||
WalletDB btcwallet.LoaderOption
|
||||
|
||||
// NativeSQLStore is a pointer to a native SQL store that can be used
|
||||
// for native SQL queries for tables that already support it. This may
|
||||
// be nil if the use-native-sql flag was not set.
|
||||
NativeSQLStore *sqldb.BaseDB
|
||||
// NativeSQLStore holds a reference to the native SQL store that can
|
||||
// be used for native SQL queries for tables that already support it.
|
||||
// This may be nil if the use-native-sql flag was not set.
|
||||
NativeSQLStore sqldb.DB
|
||||
|
||||
// Remote indicates whether the database backends are remote, possibly
|
||||
// replicated instances or local bbolt or sqlite backed databases.
|
||||
@@ -449,7 +452,7 @@ func (db *DB) GetBackends(ctx context.Context, chanDBPath,
|
||||
}
|
||||
closeFuncs[NSWalletDB] = postgresWalletBackend.Close
|
||||
|
||||
var nativeSQLStore *sqldb.BaseDB
|
||||
var nativeSQLStore sqldb.DB
|
||||
if db.UseNativeSQL {
|
||||
nativePostgresStore, err := sqldb.NewPostgresStore(
|
||||
db.Postgres,
|
||||
@@ -459,7 +462,7 @@ func (db *DB) GetBackends(ctx context.Context, chanDBPath,
|
||||
"native postgres store: %v", err)
|
||||
}
|
||||
|
||||
nativeSQLStore = nativePostgresStore.BaseDB
|
||||
nativeSQLStore = nativePostgresStore
|
||||
closeFuncs[PostgresBackend] = nativePostgresStore.Close
|
||||
}
|
||||
|
||||
@@ -571,7 +574,7 @@ func (db *DB) GetBackends(ctx context.Context, chanDBPath,
|
||||
}
|
||||
closeFuncs[NSWalletDB] = sqliteWalletBackend.Close
|
||||
|
||||
var nativeSQLStore *sqldb.BaseDB
|
||||
var nativeSQLStore sqldb.DB
|
||||
if db.UseNativeSQL {
|
||||
nativeSQLiteStore, err := sqldb.NewSqliteStore(
|
||||
db.Sqlite,
|
||||
@@ -582,7 +585,7 @@ func (db *DB) GetBackends(ctx context.Context, chanDBPath,
|
||||
"native SQLite store: %v", err)
|
||||
}
|
||||
|
||||
nativeSQLStore = nativeSQLiteStore.BaseDB
|
||||
nativeSQLStore = nativeSQLiteStore
|
||||
closeFuncs[SqliteBackend] = nativeSQLiteStore.Close
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user