mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-18 10:06:51 +01:00
multi: pass in a MigrationConfig to all optional migrations
Define a MigrationConfig interface that should be used to pass the config of an optional migration function. An implementation of this interface is added for migration30 (the only current optional migration).
This commit is contained in:
@@ -23,10 +23,17 @@ import (
|
||||
// indexes.
|
||||
const recordsPerTx = 20_000
|
||||
|
||||
// MigrateRevLogConfig is an interface that defines the config that should be
|
||||
// passed to the MigrateRevocationLog function.
|
||||
type MigrateRevLogConfig interface{}
|
||||
|
||||
// MigrateRevLogConfigImpl implements the MigrationRevLogConfig interface.
|
||||
type MigrateRevLogConfigImpl struct{}
|
||||
|
||||
// MigrateRevocationLog migrates the old revocation logs into the newer format
|
||||
// and deletes them once finished, with the deletion only happens once ALL the
|
||||
// old logs have been migrates.
|
||||
func MigrateRevocationLog(db kvdb.Backend) error {
|
||||
func MigrateRevocationLog(db kvdb.Backend, _ MigrateRevLogConfig) error {
|
||||
log.Infof("Migrating revocation logs, might take a while...")
|
||||
|
||||
var (
|
||||
|
||||
@@ -103,11 +103,15 @@ func TestMigrateRevocationLog(t *testing.T) {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := &MigrateRevLogConfigImpl{}
|
||||
|
||||
migtest.ApplyMigrationWithDB(
|
||||
t,
|
||||
beforeMigration,
|
||||
afterMigration,
|
||||
MigrateRevocationLog,
|
||||
func(db kvdb.Backend) error {
|
||||
return MigrateRevocationLog(db, cfg)
|
||||
},
|
||||
false,
|
||||
)
|
||||
})
|
||||
@@ -559,6 +563,8 @@ func BenchmarkMigration(b *testing.B) {
|
||||
return setupTestLogs(db, c, oldLogs, nil)
|
||||
}
|
||||
|
||||
cfg := &MigrateRevLogConfigImpl{}
|
||||
|
||||
// Run the migration test.
|
||||
migtest.ApplyMigrationWithDB(
|
||||
b,
|
||||
@@ -568,7 +574,7 @@ func BenchmarkMigration(b *testing.B) {
|
||||
b.StartTimer()
|
||||
defer b.StopTimer()
|
||||
|
||||
return MigrateRevocationLog(db)
|
||||
return MigrateRevocationLog(db, cfg)
|
||||
},
|
||||
false,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user