multi: move global registeredChains to cfg

This commit is contained in:
Oliver Gugger
2020-05-14 13:37:32 +02:00
parent a7e78112b7
commit 85d5cdfbfd
7 changed files with 27 additions and 23 deletions

View File

@@ -247,6 +247,10 @@ type Config struct {
ProtocolOptions *lncfg.ProtocolOptions `group:"protocol" namespace:"protocol"`
AllowCircularRoute bool `long:"allow-circular-route" description:"If true, our node will allow htlc forwards that arrive and depart on the same channel."`
// registeredChains keeps track of all chains that have been registered
// with the daemon.
registeredChains *chainRegistry
}
// DefaultConfig returns all default values for the Config struct.
@@ -349,6 +353,7 @@ func DefaultConfig() Config {
},
MaxOutgoingCltvExpiry: htlcswitch.DefaultMaxOutgoingCltvExpiry,
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
registeredChains: newChainRegistry(),
}
}
@@ -736,7 +741,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
// Finally we'll register the litecoin chain as our current
// primary chain.
registeredChains.RegisterPrimaryChain(litecoinChain)
cfg.registeredChains.RegisterPrimaryChain(litecoinChain)
MaxFundingAmount = maxLtcFundingAmount
MaxPaymentMSat = maxLtcPaymentMSat
@@ -823,7 +828,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
// Finally we'll register the bitcoin chain as our current
// primary chain.
registeredChains.RegisterPrimaryChain(bitcoinChain)
cfg.registeredChains.RegisterPrimaryChain(bitcoinChain)
}
// Ensure that the user didn't attempt to specify negative values for
@@ -878,7 +883,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
// store all the data specific to this chain/network.
networkDir = filepath.Join(
cfg.DataDir, defaultChainSubDirname,
registeredChains.PrimaryChain().String(),
cfg.registeredChains.PrimaryChain().String(),
normalizeNetwork(activeNetParams.Name),
)
@@ -912,7 +917,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
// Append the network type to the log directory so it is "namespaced"
// per network in the same fashion as the data directory.
cfg.LogDir = filepath.Join(cfg.LogDir,
registeredChains.PrimaryChain().String(),
cfg.registeredChains.PrimaryChain().String(),
normalizeNetwork(activeNetParams.Name))
// Special show command to list supported subsystems and exit.