Skip to content

Commit 8d26289

Browse files
committed
Merge pull request #6961
fa41d4c [qt] Move GUI related HelpMessage() part downstream (MarcoFalke) faf93f3 [trivial] Reuse translation and cleanup DEFAULT_* values (MarcoFalke) 3307bdb Bugfix: Omit wallet-related options from -help when wallet is not supported (Luke Dashjr) b966aa8 Constrain constant values to a single location in code (Luke Dashjr)
2 parents 92aa731 + fa41d4c commit 8d26289

29 files changed

+157
-99
lines changed

src/bitcoin-cli.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@
2222

2323
using namespace std;
2424

25+
static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
2526
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
2627

2728
std::string HelpMessageCli()
2829
{
2930
string strUsage;
3031
strUsage += HelpMessageGroup(_("Options:"));
3132
strUsage += HelpMessageOpt("-?", _("This help message"));
32-
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "bitcoin.conf"));
33+
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), BITCOIN_CONF_FILENAME));
3334
strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory"));
3435
AppendParamsHelpMessages(strUsage);
35-
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), "127.0.0.1"));
36+
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), DEFAULT_RPCCONNECT));
3637
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), 8332, 18332));
3738
strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
3839
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
@@ -141,7 +142,7 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
141142

142143
UniValue CallRPC(const string& strMethod, const UniValue& params)
143144
{
144-
std::string host = GetArg("-rpcconnect", "127.0.0.1");
145+
std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT);
145146
int port = GetArg("-rpcport", BaseParams().RPCPort());
146147

147148
// Create event base

src/init.cpp

Lines changed: 54 additions & 64 deletions
Large diffs are not rendered by default.

src/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ bool fReindex = false;
6666
bool fTxIndex = false;
6767
bool fHavePruned = false;
6868
bool fPruneMode = false;
69-
bool fIsBareMultisigStd = true;
69+
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
7070
bool fRequireStandard = true;
7171
bool fCheckBlockIndex = false;
72-
bool fCheckpointsEnabled = true;
72+
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
7373
size_t nCoinCacheUsage = 5000 * 300;
7474
uint64_t nPruneTarget = 0;
7575
bool fAlerts = DEFAULT_ALERTS;
@@ -941,7 +941,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
941941
CAmount mempoolRejectFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nSize);
942942
if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
943943
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
944-
} else if (GetBoolArg("-relaypriority", true) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) {
944+
} else if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) {
945945
// Require that free transactions have sufficient priority to be mined in the next block.
946946
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority");
947947
}
@@ -963,7 +963,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
963963
nLastTime = nNow;
964964
// -limitfreerelay unit is thousand-bytes-per-minute
965965
// At default rate it would take over a month to fill 1GB
966-
if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000)
966+
if (dFreeCount >= GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) * 10 * 1000)
967967
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "rate limited free transaction");
968968
LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize);
969969
dFreeCount += nSize;
@@ -1436,7 +1436,7 @@ void Misbehaving(NodeId pnode, int howmuch)
14361436
return;
14371437

14381438
state->nMisbehavior += howmuch;
1439-
int banscore = GetArg("-banscore", 100);
1439+
int banscore = GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD);
14401440
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
14411441
{
14421442
LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
@@ -3605,7 +3605,7 @@ bool InitBlockIndex(const CChainParams& chainparams)
36053605
return true;
36063606

36073607
// Use the provided setting for -txindex in the new database
3608-
fTxIndex = GetBoolArg("-txindex", false);
3608+
fTxIndex = GetBoolArg("-txindex", DEFAULT_TXINDEX);
36093609
pblocktree->WriteFlag("txindex", fTxIndex);
36103610
LogPrintf("Initializing databases...\n");
36113611

@@ -3936,7 +3936,7 @@ std::string GetWarnings(const std::string& strFor)
39363936
if (!CLIENT_VERSION_IS_RELEASE)
39373937
strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
39383938

3939-
if (GetBoolArg("-testsafemode", false))
3939+
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
39403940
strStatusBar = strRPC = "testsafemode enabled";
39413941

39423942
// Misc warnings like out of disk space and clock is wrong

src/main.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
6464
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
6565
/** The pre-allocation chunk size for rev?????.dat files (since 0.8) */
6666
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
67+
6768
/** Maximum number of script-checking threads allowed */
6869
static const int MAX_SCRIPTCHECK_THREADS = 16;
6970
/** -par default (number of script-checking threads, 0 = auto) */
@@ -86,6 +87,16 @@ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
8687
static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
8788
/** Maximum length of reject messages. */
8889
static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111;
90+
static const unsigned int DEFAULT_LIMITFREERELAY = 15;
91+
static const bool DEFAULT_RELAYPRIORITY = true;
92+
93+
/** Default for -permitbaremultisig */
94+
static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
95+
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
96+
static const bool DEFAULT_TXINDEX = false;
97+
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
98+
99+
static const bool DEFAULT_TESTSAFEMODE = false;
89100

90101
struct BlockHasher
91102
{

src/miner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
153153
// Priority order to process transactions
154154
list<COrphan> vOrphan; // list memory doesn't move
155155
map<uint256, vector<COrphan*> > mapDependers;
156-
bool fPrintPriority = GetBoolArg("-printpriority", false);
156+
bool fPrintPriority = GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
157157

158158
// This vector will be sorted into a priority queue:
159159
vector<TxPriority> vecPriority;

src/miner.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ class CScript;
1717
class CWallet;
1818
namespace Consensus { struct Params; };
1919

20+
static const bool DEFAULT_GENERATE = false;
2021
static const int DEFAULT_GENERATE_THREADS = 1;
2122

23+
static const bool DEFAULT_PRINTPRIORITY = false;
24+
2225
struct CBlockTemplate
2326
{
2427
CBlock block;

src/net.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,11 @@ void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t banti
521521
banEntry.banReason = banReason;
522522
if (bantimeoffset <= 0)
523523
{
524-
bantimeoffset = GetArg("-bantime", 60*60*24); // Default 24-hour ban
524+
bantimeoffset = GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME);
525525
sinceUnixEpoch = false;
526526
}
527527
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset;
528528

529-
530529
LOCK(cs_setBanned);
531530
if (setBanned[subNet].nBanUntil < banEntry.nBanUntil)
532531
setBanned[subNet] = banEntry;
@@ -1414,7 +1413,7 @@ void ThreadDNSAddressSeed()
14141413
{
14151414
// goal: only query DNS seeds if address need is acute
14161415
if ((addrman.size() > 0) &&
1417-
(!GetBoolArg("-forcednsseed", false))) {
1416+
(!GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) {
14181417
MilliSleep(11 * 1000);
14191418

14201419
LOCK(cs_vNodes);
@@ -2337,8 +2336,8 @@ bool CAddrDB::Read(CAddrMan& addr)
23372336
return true;
23382337
}
23392338

2340-
unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
2341-
unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
2339+
unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); }
2340+
unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER); }
23422341

23432342
CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNameIn, bool fInboundIn) :
23442343
ssSend(SER_NETWORK, INIT_PROTO_VERSION),

src/net.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
6565
/** Default for blocks only*/
6666
static const bool DEFAULT_BLOCKSONLY = false;
6767

68+
static const bool DEFAULT_FORCEDNSSEED = false;
69+
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
70+
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
71+
72+
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
73+
static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
74+
6875
unsigned int ReceiveFloodSize();
6976
unsigned int SendBufferSize();
7077

src/netbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static proxyType proxyInfo[NET_MAX];
4040
static proxyType nameProxy;
4141
static CCriticalSection cs_proxyInfos;
4242
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
43-
bool fNameLookup = false;
43+
bool fNameLookup = DEFAULT_NAME_LOOKUP;
4444

4545
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
4646

src/netbase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
extern int nConnectTimeout;
2020
extern bool fNameLookup;
2121

22-
/** -timeout default */
22+
//! -timeout default
2323
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
24+
//! -dns default
25+
static const int DEFAULT_NAME_LOOKUP = true;
2426

2527
#ifdef WIN32
2628
// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error

0 commit comments

Comments
 (0)