Move MinWallets to netParams.
We already have a file with hard-coded parameters for each Decred network, so having logic to figure out parameters later is unnecessary.
This commit is contained in:
parent
d4b3d2fafb
commit
e0b0630248
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2020-2021 The Decred developers
|
||||
// Copyright (c) 2020-2022 The Decred developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
@ -276,13 +276,11 @@ func loadConfig() (*config, error) {
|
||||
}
|
||||
|
||||
// Set the active network.
|
||||
minRequired := 1
|
||||
switch cfg.Network {
|
||||
case "testnet":
|
||||
cfg.netParams = &testNet3Params
|
||||
case "mainnet":
|
||||
cfg.netParams = &mainNetParams
|
||||
minRequired = 3
|
||||
case "simnet":
|
||||
cfg.netParams = &simNetParams
|
||||
}
|
||||
@ -388,9 +386,9 @@ func loadConfig() (*config, error) {
|
||||
}
|
||||
|
||||
// Verify minimum number of voting wallets are configured.
|
||||
if numHost < minRequired {
|
||||
if numHost < cfg.netParams.MinWallets {
|
||||
return nil, fmt.Errorf("minimum required voting wallets has not been met: %d < %d",
|
||||
numHost, minRequired)
|
||||
numHost, cfg.netParams.MinWallets)
|
||||
}
|
||||
|
||||
// Add default port for the active network if there is no port specified.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2020 The Decred developers
|
||||
// Copyright (c) 2020-2022 The Decred developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
@ -13,6 +13,10 @@ type netParams struct {
|
||||
DcrdRPCServerPort string
|
||||
WalletRPCServerPort string
|
||||
BlockExplorerURL string
|
||||
// MinWallets is the minimum number of voting wallets required for a vspd
|
||||
// deployment on this network. vspd will log an error and refuse to start if
|
||||
// fewer wallets are configured.
|
||||
MinWallets int
|
||||
}
|
||||
|
||||
var mainNetParams = netParams{
|
||||
@ -20,6 +24,7 @@ var mainNetParams = netParams{
|
||||
DcrdRPCServerPort: "9109",
|
||||
WalletRPCServerPort: "9110",
|
||||
BlockExplorerURL: "https://dcrdata.decred.org",
|
||||
MinWallets: 3,
|
||||
}
|
||||
|
||||
var testNet3Params = netParams{
|
||||
@ -27,6 +32,7 @@ var testNet3Params = netParams{
|
||||
DcrdRPCServerPort: "19109",
|
||||
WalletRPCServerPort: "19110",
|
||||
BlockExplorerURL: "https://testnet.dcrdata.org",
|
||||
MinWallets: 1,
|
||||
}
|
||||
|
||||
var simNetParams = netParams{
|
||||
@ -34,4 +40,5 @@ var simNetParams = netParams{
|
||||
DcrdRPCServerPort: "19556",
|
||||
WalletRPCServerPort: "19557",
|
||||
BlockExplorerURL: "...",
|
||||
MinWallets: 1,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user