Skip to content

Commit 02a6702

Browse files
committed
Add option -alerts to opt out of alert system
Make it possible to opt-out of the centralized alert system by providing an option `-noalerts` or `-alerts=0`. The default remains unchanged. This is a gentler form of #6260, in which I went a bit overboard by removing the alert system completely. I intend to add this to the GUI options in another pull after this.
1 parent ebab5d3 commit 02a6702

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/init.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ std::string HelpMessage(HelpMessageMode mode)
266266
// Do not translate _(...) -help-debug options, Many technical terms, and only a very small audience, so is unnecessary stress to translators.
267267
string strUsage = HelpMessageGroup(_("Options:"));
268268
strUsage += HelpMessageOpt("-?", _("This help message"));
269+
strUsage += HelpMessageOpt("-alerts", strprintf(_("Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS));
269270
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
270271
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
271272
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
@@ -865,6 +866,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
865866
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", true);
866867
nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes);
867868

869+
fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS);
870+
868871
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
869872

870873
// Initialize elliptic curve code

src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ bool fCheckBlockIndex = false;
6161
bool fCheckpointsEnabled = true;
6262
size_t nCoinCacheUsage = 5000 * 300;
6363
uint64_t nPruneTarget = 0;
64+
bool fAlerts = DEFAULT_ALERTS;
6465

6566
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) */
6667
CFeeRate minRelayTxFee = CFeeRate(1000);
@@ -4622,7 +4623,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
46224623
}
46234624

46244625

4625-
else if (strCommand == "alert")
4626+
else if (fAlerts && strCommand == "alert")
46264627
{
46274628
CAlert alert;
46284629
vRecv >> alert;

src/main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
5252
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
5353
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
5454
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
55+
/** Default for accepting alerts from the P2P network. */
56+
static const bool DEFAULT_ALERTS = true;
5557
/** The maximum size for transactions we're willing to relay/mine */
5658
static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
5759
/** Maximum number of signature check operations in an IsStandard() P2SH script */
@@ -113,6 +115,7 @@ extern bool fCheckBlockIndex;
113115
extern bool fCheckpointsEnabled;
114116
extern size_t nCoinCacheUsage;
115117
extern CFeeRate minRelayTxFee;
118+
extern bool fAlerts;
116119

117120
/** Best header we've seen so far (used for getheaders queries' starting points). */
118121
extern CBlockIndex *pindexBestHeader;

0 commit comments

Comments
 (0)