Add whitelistforcerelay to control forced relaying. [#7099 redux]
- Add whitelistforcerelay to control forced relaying. Also renames whitelistalwaysrelay. Nodes relay all transactions from whitelisted peers, this gets in the way of some useful reasons for whitelisting peers-- for example, bypassing bandwidth limitations. The purpose of this forced relaying is for specialized gateway applications where a node is being used as a P2P connection filter and multiplexer, but where you don't want it getting in the way of (re-)broadcast. This change makes it configurable with whitelistforcerelay. - Blacklist -whitelistalwaysrelay; replaced by -whitelistrelay. Github-Pull: #7439 Rebased-From: 325c725fb6205e38142914acb9ed1733d8482d46 89d113e02a83617b4e971c160d47551476dacc71
This commit is contained in:
parent
e2d9a58588
commit
86755bc85a
18
src/init.cpp
18
src/init.cpp
@ -388,7 +388,8 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
|
strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
|
||||||
strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") +
|
strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") +
|
||||||
" " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway"));
|
" " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway"));
|
||||||
strUsage += HelpMessageOpt("-whitelistalwaysrelay", strprintf(_("Always relay transactions received from whitelisted peers (default: %d)"), DEFAULT_WHITELISTALWAYSRELAY));
|
strUsage += HelpMessageOpt("-whitelistrelay", strprintf(_("Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)"), DEFAULT_WHITELISTRELAY));
|
||||||
|
strUsage += HelpMessageOpt("-whitelistforcerelay", strprintf(_("Force relay of transactions from whitelisted peers even they violate local relay policy (default: %d)"), DEFAULT_WHITELISTFORCERELAY));
|
||||||
strUsage += HelpMessageOpt("-maxuploadtarget=<n>", strprintf(_("Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), DEFAULT_MAX_UPLOAD_TARGET));
|
strUsage += HelpMessageOpt("-maxuploadtarget=<n>", strprintf(_("Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), DEFAULT_MAX_UPLOAD_TARGET));
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
@ -749,15 +750,21 @@ void InitParameterInteraction()
|
|||||||
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable walletbroadcast and whitelistalwaysrelay in blocksonly mode
|
// disable walletbroadcast and whitelistrelay in blocksonly mode
|
||||||
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
|
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
|
||||||
if (SoftSetBoolArg("-whitelistalwaysrelay", false))
|
if (SoftSetBoolArg("-whitelistrelay", false))
|
||||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistalwaysrelay=0\n", __func__);
|
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (SoftSetBoolArg("-walletbroadcast", false))
|
if (SoftSetBoolArg("-walletbroadcast", false))
|
||||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
|
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forcing relay from whitelisted hosts implies we will accept relays from them in the first place.
|
||||||
|
if (GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
|
||||||
|
if (SoftSetBoolArg("-whitelistrelay", true))
|
||||||
|
LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitLogging()
|
void InitLogging()
|
||||||
@ -884,6 +891,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (GetBoolArg("-benchmark", false))
|
if (GetBoolArg("-benchmark", false))
|
||||||
InitWarning(_("Unsupported argument -benchmark ignored, use -debug=bench."));
|
InitWarning(_("Unsupported argument -benchmark ignored, use -debug=bench."));
|
||||||
|
|
||||||
|
if (GetBoolArg("-whitelistalwaysrelay", false))
|
||||||
|
InitWarning(_("Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
|
||||||
|
|
||||||
// Checkmempool and checkblockindex default to true in regtest mode
|
// Checkmempool and checkblockindex default to true in regtest mode
|
||||||
int ratio = std::min<int>(std::max<int>(GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
int ratio = std::min<int>(std::max<int>(GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
||||||
if (ratio != 0) {
|
if (ratio != 0) {
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -4497,8 +4497,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
|
|
||||||
bool fBlocksOnly = GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
|
bool fBlocksOnly = GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
|
||||||
|
|
||||||
// Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistalwaysrelay is true
|
// Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true
|
||||||
if (pfrom->fWhitelisted && GetBoolArg("-whitelistalwaysrelay", DEFAULT_WHITELISTALWAYSRELAY))
|
if (pfrom->fWhitelisted && GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))
|
||||||
fBlocksOnly = false;
|
fBlocksOnly = false;
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
@ -4677,8 +4677,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
else if (strCommand == NetMsgType::TX)
|
else if (strCommand == NetMsgType::TX)
|
||||||
{
|
{
|
||||||
// Stop processing the transaction early if
|
// Stop processing the transaction early if
|
||||||
// We are in blocks only mode and peer is either not whitelisted or whitelistalwaysrelay is off
|
// We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off
|
||||||
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistalwaysrelay", DEFAULT_WHITELISTALWAYSRELAY)))
|
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
|
||||||
{
|
{
|
||||||
LogPrint("net", "transaction sent in violation of protocol peer=%d\n", pfrom->id);
|
LogPrint("net", "transaction sent in violation of protocol peer=%d\n", pfrom->id);
|
||||||
return true;
|
return true;
|
||||||
@ -4778,7 +4778,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
assert(recentRejects);
|
assert(recentRejects);
|
||||||
recentRejects->insert(tx.GetHash());
|
recentRejects->insert(tx.GetHash());
|
||||||
|
|
||||||
if (pfrom->fWhitelisted && GetBoolArg("-whitelistalwaysrelay", DEFAULT_WHITELISTALWAYSRELAY)) {
|
if (pfrom->fWhitelisted && GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
|
||||||
// Always relay transactions received from whitelisted peers, even
|
// Always relay transactions received from whitelisted peers, even
|
||||||
// if they were already in the mempool or rejected from it due
|
// if they were already in the mempool or rejected from it due
|
||||||
// to policy, allowing the node to function as a gateway for
|
// to policy, allowing the node to function as a gateway for
|
||||||
|
@ -42,8 +42,10 @@ struct CNodeStateStats;
|
|||||||
|
|
||||||
/** Default for accepting alerts from the P2P network. */
|
/** Default for accepting alerts from the P2P network. */
|
||||||
static const bool DEFAULT_ALERTS = true;
|
static const bool DEFAULT_ALERTS = true;
|
||||||
/** Default for DEFAULT_WHITELISTALWAYSRELAY. */
|
/** Default for DEFAULT_WHITELISTRELAY. */
|
||||||
static const bool DEFAULT_WHITELISTALWAYSRELAY = true;
|
static const bool DEFAULT_WHITELISTRELAY = true;
|
||||||
|
/** Default for DEFAULT_WHITELISTFORCERELAY. */
|
||||||
|
static const bool DEFAULT_WHITELISTFORCERELAY = true;
|
||||||
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
||||||
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
|
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
|
||||||
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
|
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
|
||||||
|
Loading…
Reference in New Issue
Block a user