From e0b0630248dd08d8bb48361ec5f1998ce45ff8ae Mon Sep 17 00:00:00 2001 From: jholdstock Date: Thu, 31 Mar 2022 09:38:06 +0100 Subject: [PATCH] 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. --- config.go | 8 +++----- params.go | 9 ++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index 14eb30b..0934280 100644 --- a/config.go +++ b/config.go @@ -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. diff --git a/params.go b/params.go index 56ff829..54ffc9a 100644 --- a/params.go +++ b/params.go @@ -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, }