mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 06:32:18 +02:00
multi: add sqlite backend option
In this diff, we expose the option to use sqlite as a db backend.
This commit is contained in:
49
config.go
49
config.go
@@ -1404,12 +1404,18 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
)
|
||||
}
|
||||
|
||||
towerDir := filepath.Join(
|
||||
cfg.Watchtower.TowerDir,
|
||||
cfg.registeredChains.PrimaryChain().String(),
|
||||
lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name),
|
||||
)
|
||||
|
||||
// Create the lnd directory and all other sub-directories if they don't
|
||||
// already exist. This makes sure that directory trees are also created
|
||||
// for files that point to outside the lnddir.
|
||||
dirs := []string{
|
||||
lndDir, cfg.DataDir, cfg.networkDir,
|
||||
cfg.LetsEncryptDir, cfg.Watchtower.TowerDir,
|
||||
cfg.LetsEncryptDir, towerDir, cfg.graphDatabaseDir(),
|
||||
filepath.Dir(cfg.TLSCertPath), filepath.Dir(cfg.TLSKeyPath),
|
||||
filepath.Dir(cfg.AdminMacPath), filepath.Dir(cfg.ReadMacPath),
|
||||
filepath.Dir(cfg.InvoiceMacPath),
|
||||
@@ -1616,6 +1622,47 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
cfg.DB.Bolt.NoFreelistSync = !cfg.SyncFreelist
|
||||
}
|
||||
|
||||
// Parse any extra sqlite pragma options that may have been provided
|
||||
// to determine if they override any of the defaults that we will
|
||||
// otherwise add.
|
||||
var (
|
||||
defaultSynchronous = true
|
||||
defaultAutoVacuum = true
|
||||
defaultFullfsync = true
|
||||
)
|
||||
for _, option := range cfg.DB.Sqlite.PragmaOptions {
|
||||
switch {
|
||||
case strings.HasPrefix(option, "synchronous="):
|
||||
defaultSynchronous = false
|
||||
|
||||
case strings.HasPrefix(option, "auto_vacuum="):
|
||||
defaultAutoVacuum = false
|
||||
|
||||
case strings.HasPrefix(option, "fullfsync="):
|
||||
defaultFullfsync = false
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if defaultSynchronous {
|
||||
cfg.DB.Sqlite.PragmaOptions = append(
|
||||
cfg.DB.Sqlite.PragmaOptions, "synchronous=full",
|
||||
)
|
||||
}
|
||||
|
||||
if defaultAutoVacuum {
|
||||
cfg.DB.Sqlite.PragmaOptions = append(
|
||||
cfg.DB.Sqlite.PragmaOptions, "auto_vacuum=incremental",
|
||||
)
|
||||
}
|
||||
|
||||
if defaultFullfsync {
|
||||
cfg.DB.Sqlite.PragmaOptions = append(
|
||||
cfg.DB.Sqlite.PragmaOptions, "fullfsync=true",
|
||||
)
|
||||
}
|
||||
|
||||
// Ensure that the user hasn't chosen a remote-max-htlc value greater
|
||||
// than the protocol maximum.
|
||||
maxRemoteHtlcs := uint16(input.MaxHTLCNumber / 2)
|
||||
|
Reference in New Issue
Block a user