mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
channeldb+lnd: make channeldb backend configurable
This commit adds support for user configured channeldb backend.
This commit is contained in:
parent
9d57c1a6b4
commit
0e3629e2c7
@ -1096,8 +1096,8 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
||||
|
||||
// localDatabaseDir returns the default directory where the
|
||||
// local bolt db files are stored.
|
||||
func (c *config) localDatabaseDir() string {
|
||||
return filepath.Join(cfg.DataDir,
|
||||
func (c *Config) localDatabaseDir() string {
|
||||
return filepath.Join(c.DataDir,
|
||||
defaultGraphSubDirname,
|
||||
normalizeNetwork(activeNetParams.Name))
|
||||
}
|
||||
|
10
lnd.go
10
lnd.go
@ -250,11 +250,17 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
ltndLog.Infof("Opening the main database, this might take a few " +
|
||||
"minutes...")
|
||||
|
||||
chanDbBackend, err := cfg.DB.GetBackend(cfg.localDatabaseDir())
|
||||
if err != nil {
|
||||
ltndLog.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Open the channeldb, which is dedicated to storing channel, and
|
||||
// network related metadata.
|
||||
startOpenTime := time.Now()
|
||||
chanDB, err := channeldb.Open(
|
||||
cfg.localDatabaseDir(),
|
||||
chanDB, err := channeldb.CreateWithBackend(
|
||||
chanDbBackend,
|
||||
channeldb.OptionSetRejectCacheSize(cfg.Caches.RejectCacheSize),
|
||||
channeldb.OptionSetChannelCacheSize(cfg.Caches.ChannelCacheSize),
|
||||
channeldb.OptionSetSyncFreelist(cfg.SyncFreelist),
|
||||
|
@ -377,8 +377,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
|
||||
|
||||
// Initialize the sphinx router, placing it's persistent replay log in
|
||||
// the same directory as the channel graph database.
|
||||
graphDir := chanDB.Path()
|
||||
sharedSecretPath := filepath.Join(graphDir, "sphinxreplay.db")
|
||||
sharedSecretPath := filepath.Join(cfg.localDatabaseDir(), "sphinxreplay.db")
|
||||
replayLog := htlcswitch.NewDecayedLog(sharedSecretPath, cc.chainNotifier)
|
||||
sphinxRouter := sphinx.NewRouter(
|
||||
nodeKeyECDH, activeNetParams.Params, replayLog,
|
||||
|
Loading…
Reference in New Issue
Block a user