multi: move global networkDir to cfg
This commit is contained in:
parent
85d5cdfbfd
commit
d44f205e3f
15
config.go
15
config.go
@ -251,6 +251,11 @@ type Config struct {
|
||||
// registeredChains keeps track of all chains that have been registered
|
||||
// with the daemon.
|
||||
registeredChains *chainRegistry
|
||||
|
||||
// networkDir is the path to the directory of the currently active
|
||||
// network. This path will hold the files related to each different
|
||||
// network.
|
||||
networkDir string
|
||||
}
|
||||
|
||||
// DefaultConfig returns all default values for the Config struct.
|
||||
@ -881,7 +886,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
||||
|
||||
// We'll now construct the network directory which will be where we
|
||||
// store all the data specific to this chain/network.
|
||||
networkDir = filepath.Join(
|
||||
cfg.networkDir = filepath.Join(
|
||||
cfg.DataDir, defaultChainSubDirname,
|
||||
cfg.registeredChains.PrimaryChain().String(),
|
||||
normalizeNetwork(activeNetParams.Name),
|
||||
@ -892,17 +897,17 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
||||
// the path for the macaroons to be generated.
|
||||
if cfg.AdminMacPath == "" {
|
||||
cfg.AdminMacPath = filepath.Join(
|
||||
networkDir, defaultAdminMacFilename,
|
||||
cfg.networkDir, defaultAdminMacFilename,
|
||||
)
|
||||
}
|
||||
if cfg.ReadMacPath == "" {
|
||||
cfg.ReadMacPath = filepath.Join(
|
||||
networkDir, defaultReadMacFilename,
|
||||
cfg.networkDir, defaultReadMacFilename,
|
||||
)
|
||||
}
|
||||
if cfg.InvoiceMacPath == "" {
|
||||
cfg.InvoiceMacPath = filepath.Join(
|
||||
networkDir, defaultInvoiceMacFilename,
|
||||
cfg.networkDir, defaultInvoiceMacFilename,
|
||||
)
|
||||
}
|
||||
|
||||
@ -910,7 +915,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
||||
// we'll update the file location to match our set network directory.
|
||||
if cfg.BackupFilePath == "" {
|
||||
cfg.BackupFilePath = filepath.Join(
|
||||
networkDir, chanbackup.DefaultBackupFileName,
|
||||
cfg.networkDir, chanbackup.DefaultBackupFileName,
|
||||
)
|
||||
}
|
||||
|
||||
|
9
lnd.go
9
lnd.go
@ -53,11 +53,6 @@ import (
|
||||
|
||||
var (
|
||||
cfg *Config
|
||||
|
||||
// networkDir is the path to the directory of the currently active
|
||||
// network. This path will hold the files related to each different
|
||||
// network.
|
||||
networkDir string
|
||||
)
|
||||
|
||||
// WalletUnlockerAuthOptions returns a list of DialOptions that can be used to
|
||||
@ -428,7 +423,7 @@ func Main(config *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) erro
|
||||
if !cfg.NoMacaroons {
|
||||
// Create the macaroon authentication/authorization service.
|
||||
macaroonService, err = macaroons.NewService(
|
||||
networkDir, macaroons.IPLockChecker,
|
||||
cfg.networkDir, macaroons.IPLockChecker,
|
||||
)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to set up macaroon "+
|
||||
@ -1000,7 +995,7 @@ func waitForWalletPassword(restEndpoints []net.Addr,
|
||||
// deleted within it and recreated when successfully changing the
|
||||
// wallet's password.
|
||||
macaroonFiles := []string{
|
||||
filepath.Join(networkDir, macaroons.DBFilename),
|
||||
filepath.Join(cfg.networkDir, macaroons.DBFilename),
|
||||
cfg.AdminMacPath, cfg.ReadMacPath, cfg.InvoiceMacPath,
|
||||
}
|
||||
pwService := walletunlocker.New(
|
||||
|
@ -585,7 +585,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
|
||||
// the dependencies they need are properly populated within each sub
|
||||
// server configuration struct.
|
||||
err = subServerCgs.PopulateDependencies(
|
||||
s.cc, networkDir, macService, atpl, invoiceRegistry,
|
||||
s.cc, cfg.networkDir, macService, atpl, invoiceRegistry,
|
||||
s.htlcSwitch, activeNetParams.Params, s.chanRouter,
|
||||
routerBackend, s.nodeSigner, s.chanDB, s.sweeper, tower,
|
||||
s.towerClient, cfg.net.ResolveTCPAddr, genInvoiceFeatures,
|
||||
|
Loading…
Reference in New Issue
Block a user