multi: Add decayedlog db migration code
This commit adds the migration code for the decayedlog db which is optional and will default to true.
This commit is contained in:
7 files changed
+62
-5
No files matched your search
@@ -2,6 +2,7 @@ package channeldb
|
||||
|
||||
import (
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -29,6 +30,14 @@ type OptionalMiragtionConfig struct {
|
||||
// migrations should be run. The index in the array corresponds to the
|
||||
// migration number in optionalVersions.
|
||||
MigrationFlags []bool
|
||||
|
||||
// DecayedLog is a reference to the decayed log database. The channeldb
|
||||
// is inherently part of the optional migration flow so there is no need
|
||||
// to specify it here. The DecayedLog is a separate database in case the
|
||||
// kvdb backend is set to `bbolt`. And also for the kvdb SQL backend
|
||||
// case it is a separate table therefore we need to reference it here
|
||||
// as well to use the right query to access the decayed log.
|
||||
DecayedLog kvdb.Backend
|
||||
}
|
||||
|
||||
// NewOptionalMiragtionConfig creates a new OptionalMiragtionConfig with the
|
||||
@@ -136,3 +145,21 @@ func OptionPruneRevocationLog(prune bool) OptionModifier {
|
||||
o.OptionalMiragtionConfig.MigrationFlags[0] = prune
|
||||
}
|
||||
}
|
||||
|
||||
// OptionWithDecayedLogDB sets the decayed log database reference which might
|
||||
// be used for some migrations because generally we only touch the channeldb
|
||||
// databases in the migrations, this is a way to allow also access to the
|
||||
// decayed log database.
|
||||
func OptionWithDecayedLogDB(decayedLog kvdb.Backend) OptionModifier {
|
||||
return func(o *Options) {
|
||||
o.OptionalMiragtionConfig.DecayedLog = decayedLog
|
||||
}
|
||||
}
|
||||
|
||||
// OptionGcDecayedLog specifies whether the decayed log migration has to
|
||||
// take place.
|
||||
func OptionGcDecayedLog(noGc bool) OptionModifier {
|
||||
return func(o *Options) {
|
||||
o.OptionalMiragtionConfig.MigrationFlags[1] = !noGc
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user