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
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
@ -276,13 +276,11 @@ func loadConfig() (*config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the active network.
|
// Set the active network.
|
||||||
minRequired := 1
|
|
||||||
switch cfg.Network {
|
switch cfg.Network {
|
||||||
case "testnet":
|
case "testnet":
|
||||||
cfg.netParams = &testNet3Params
|
cfg.netParams = &testNet3Params
|
||||||
case "mainnet":
|
case "mainnet":
|
||||||
cfg.netParams = &mainNetParams
|
cfg.netParams = &mainNetParams
|
||||||
minRequired = 3
|
|
||||||
case "simnet":
|
case "simnet":
|
||||||
cfg.netParams = &simNetParams
|
cfg.netParams = &simNetParams
|
||||||
}
|
}
|
||||||
@ -388,9 +386,9 @@ func loadConfig() (*config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify minimum number of voting wallets are configured.
|
// 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",
|
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.
|
// 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
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
@ -13,6 +13,10 @@ type netParams struct {
|
|||||||
DcrdRPCServerPort string
|
DcrdRPCServerPort string
|
||||||
WalletRPCServerPort string
|
WalletRPCServerPort string
|
||||||
BlockExplorerURL 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{
|
var mainNetParams = netParams{
|
||||||
@ -20,6 +24,7 @@ var mainNetParams = netParams{
|
|||||||
DcrdRPCServerPort: "9109",
|
DcrdRPCServerPort: "9109",
|
||||||
WalletRPCServerPort: "9110",
|
WalletRPCServerPort: "9110",
|
||||||
BlockExplorerURL: "https://dcrdata.decred.org",
|
BlockExplorerURL: "https://dcrdata.decred.org",
|
||||||
|
MinWallets: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
var testNet3Params = netParams{
|
var testNet3Params = netParams{
|
||||||
@ -27,6 +32,7 @@ var testNet3Params = netParams{
|
|||||||
DcrdRPCServerPort: "19109",
|
DcrdRPCServerPort: "19109",
|
||||||
WalletRPCServerPort: "19110",
|
WalletRPCServerPort: "19110",
|
||||||
BlockExplorerURL: "https://testnet.dcrdata.org",
|
BlockExplorerURL: "https://testnet.dcrdata.org",
|
||||||
|
MinWallets: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
var simNetParams = netParams{
|
var simNetParams = netParams{
|
||||||
@ -34,4 +40,5 @@ var simNetParams = netParams{
|
|||||||
DcrdRPCServerPort: "19556",
|
DcrdRPCServerPort: "19556",
|
||||||
WalletRPCServerPort: "19557",
|
WalletRPCServerPort: "19557",
|
||||||
BlockExplorerURL: "...",
|
BlockExplorerURL: "...",
|
||||||
|
MinWallets: 1,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user