Skip to content

Commit 581ddff

Browse files
committed
net: Add fRelayTxes flag
Add a fRelayTxes to keep track of the relay transaction flag we send to other peers.
1 parent 169d379 commit 581ddff

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
11021102
fListen = GetBoolArg("-listen", DEFAULT_LISTEN);
11031103
fDiscover = GetBoolArg("-discover", true);
11041104
fNameLookup = GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
1105+
fRelayTxes = !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
11051106

11061107
bool fBound = false;
11071108
if (fListen) {

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4751,7 +4751,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
47514751
return error("message inv size() = %u", vInv.size());
47524752
}
47534753

4754-
bool fBlocksOnly = GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
4754+
bool fBlocksOnly = !fRelayTxes;
47554755

47564756
// Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true
47574757
if (pfrom->fWhitelisted && GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))
@@ -4934,7 +4934,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49344934
{
49354935
// Stop processing the transaction early if
49364936
// We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off
4937-
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
4937+
if (!fRelayTxes && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
49384938
{
49394939
LogPrint("net", "transaction sent in violation of protocol peer=%d\n", pfrom->id);
49404940
return true;

src/net.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*";
7777
bool fDiscover = true;
7878
bool fListen = true;
7979
uint64_t nLocalServices = NODE_NETWORK;
80+
bool fRelayTxes = true;
8081
CCriticalSection cs_mapLocalHost;
8182
map<CNetAddr, LocalServiceInfo> mapLocalHost;
8283
static bool vfLimited[NET_MAX] = {};
@@ -454,7 +455,7 @@ void CNode::PushVersion()
454455
else
455456
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
456457
PushMessage(NetMsgType::VERSION, PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
457-
nLocalHostNonce, strSubVersion, nBestHeight, !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY));
458+
nLocalHostNonce, strSubVersion, nBestHeight, fRelayTxes);
458459
}
459460

460461

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
153153
extern bool fDiscover;
154154
extern bool fListen;
155155
extern uint64_t nLocalServices;
156+
extern bool fRelayTxes;
156157
extern uint64_t nLocalHostNonce;
157158
extern CAddrMan addrman;
158159

0 commit comments

Comments
 (0)