diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-12-02 14:38:17 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-12-02 14:38:43 +0100 |
commit | df2ced5c8325b84557f185b687e6c014de84cecf (patch) | |
tree | 62921ce38e6aef6f230a750ca9ef59339e7b6a68 /src | |
parent | 93236c0455ded01f1af5d28f8be0801120a18ff2 (diff) | |
parent | 02354c93bed8d556b8c9075e3ca8601c43c68267 (diff) |
Merge pull request #7128
02354c9 Constrain rpcport default values to a single location in code (Luke Dashjr)
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoin-cli.cpp | 2 | ||||
-rw-r--r-- | src/chainparamsbase.cpp | 13 | ||||
-rw-r--r-- | src/chainparamsbase.h | 2 | ||||
-rw-r--r-- | src/init.cpp | 2 |
4 files changed, 13 insertions, 6 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 58ced1ade9..2fa91e4e77 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -34,7 +34,7 @@ std::string HelpMessageCli() strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory")); AppendParamsHelpMessages(strUsage); strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), DEFAULT_RPCCONNECT)); - strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), 8332, 18332)); + strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), BaseParams(CBaseChainParams::MAIN).RPCPort(), BaseParams(CBaseChainParams::TESTNET).RPCPort())); strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start")); strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections")); diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index db2dc751f5..aa973abf7e 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -86,18 +86,23 @@ const CBaseChainParams& BaseParams() return *pCurrentBaseParams; } -void SelectBaseParams(const std::string& chain) +CBaseChainParams& BaseParams(const std::string& chain) { if (chain == CBaseChainParams::MAIN) - pCurrentBaseParams = &mainParams; + return mainParams; else if (chain == CBaseChainParams::TESTNET) - pCurrentBaseParams = &testNetParams; + return testNetParams; else if (chain == CBaseChainParams::REGTEST) - pCurrentBaseParams = ®TestParams; + return regTestParams; else throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } +void SelectBaseParams(const std::string& chain) +{ + pCurrentBaseParams = &BaseParams(chain); +} + std::string ChainNameFromCommandLine() { bool fRegTest = GetBoolArg("-regtest", false); diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index 095c4cbdcb..9c3e9a0ebf 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -42,6 +42,8 @@ void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp=true); */ const CBaseChainParams& BaseParams(); +CBaseChainParams& BaseParams(const std::string& chain); + /** Sets the params returned by Params() to those for the given network. */ void SelectBaseParams(const std::string& chain); diff --git a/src/init.cpp b/src/init.cpp index c36cf9efbc..645c8f94b1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -491,7 +491,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcauth=<userpw>", _("Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. This option can be specified multiple times")); - strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), 8332, 18332)); + strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), BaseParams(CBaseChainParams::MAIN).RPCPort(), BaseParams(CBaseChainParams::TESTNET).RPCPort())); strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times")); strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS)); if (showDebug) { |