diff --git a/chainregistry.go b/chainregistry.go index 1a6f9a00..7be92afd 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -703,7 +703,7 @@ func initNeutrinoBackend(chainDir string) (*neutrino.ChainService, func(), error } dbName := filepath.Join(dbPath, "neutrino.db") - db, err := walletdb.Create("bdb", dbName, true) + db, err := walletdb.Create("bdb", dbName, !cfg.SyncFreelist) if err != nil { return nil, nil, fmt.Errorf("unable to create neutrino "+ "database: %v", err) diff --git a/config.go b/config.go index 0800345c..dc71a75c 100644 --- a/config.go +++ b/config.go @@ -234,6 +234,7 @@ type config struct { LndDir string `long:"lnddir" description:"The base directory that contains lnd's data, logs, configuration file, etc."` ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` DataDir string `short:"b" long:"datadir" description:"The directory to store lnd's data within"` + SyncFreelist bool `long:"sync-freelist" description:"Whether the databases used within lnd should sync their freelist to disk. This is disabled by default resulting in improved memory performance during operation, but with an increase in startup time."` TLSCertPath string `long:"tlscertpath" description:"Path to write the TLS certificate for lnd's RPC and REST services"` TLSKeyPath string `long:"tlskeypath" description:"Path to write the TLS private key for lnd's RPC and REST services"` TLSExtraIPs []string `long:"tlsextraip" description:"Adds an extra ip to the generated certificate"` diff --git a/lnd.go b/lnd.go index 40cc85c8..8c0b74aa 100644 --- a/lnd.go +++ b/lnd.go @@ -190,6 +190,7 @@ func Main(lisCfg ListenerCfg) error { graphDir, channeldb.OptionSetRejectCacheSize(cfg.Caches.RejectCacheSize), channeldb.OptionSetChannelCacheSize(cfg.Caches.ChannelCacheSize), + channeldb.OptionSetSyncFreelist(cfg.SyncFreelist), ) if err != nil { err := fmt.Errorf("Unable to open channeldb: %v", err) @@ -1000,7 +1001,7 @@ func waitForWalletPassword(restEndpoints []net.Addr, cfg.AdminMacPath, cfg.ReadMacPath, cfg.InvoiceMacPath, } pwService := walletunlocker.New( - chainConfig.ChainDir, activeNetParams.Params, true, + chainConfig.ChainDir, activeNetParams.Params, !cfg.SyncFreelist, macaroonFiles, ) lnrpc.RegisterWalletUnlockerServer(grpcServer, pwService) @@ -1094,7 +1095,8 @@ func waitForWalletPassword(restEndpoints []net.Addr, chainConfig.ChainDir, activeNetParams.Params, ) loader := wallet.NewLoader( - activeNetParams.Params, netDir, true, recoveryWindow, + activeNetParams.Params, netDir, !cfg.SyncFreelist, + recoveryWindow, ) // With the seed, we can now use the wallet loader to create