diff --git a/src/init.cpp b/src/init.cpp index 293152a26b5f7..8cb664d30ffd4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1394,6 +1394,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fListen = GetBoolArg("-listen", DEFAULT_LISTEN); fDiscover = GetBoolArg("-discover", true); fNameLookup = GetBoolArg("-dns", DEFAULT_NAME_LOOKUP); + fRelayTxes = !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); bool fBound = false; if (fListen) { diff --git a/src/main.cpp b/src/main.cpp index 18a21eb47b812..85b9a75f61e77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5556,7 +5556,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return error("message inv size() = %u", vInv.size()); } - bool fBlocksOnly = GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); + bool fBlocksOnly = !fRelayTxes; // Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true if (pfrom->fWhitelisted && GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)) @@ -5746,7 +5746,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, { // Stop processing the transaction early if // We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off - if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))) + if (!fRelayTxes && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))) { LogPrint("net", "transaction sent in violation of protocol peer=%d\n", pfrom->id); return true; diff --git a/src/net.cpp b/src/net.cpp index 06a2dadfce72b..6fe0dc721f34e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -73,6 +73,7 @@ const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*"; // bool fDiscover = true; bool fListen = true; +bool fRelayTxes = true; CCriticalSection cs_mapLocalHost; std::map mapLocalHost; static bool vfLimited[NET_MAX] = {}; diff --git a/src/net.h b/src/net.h index e63381cbcf08d..f0ae9d9776ccf 100644 --- a/src/net.h +++ b/src/net.h @@ -470,6 +470,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices) extern bool fDiscover; extern bool fListen; +extern bool fRelayTxes; extern std::map mapRelay; extern std::deque > vRelayExpiration; diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 9ae97872d4af1..7c9ad7bdb2264 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -398,6 +398,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) " \"subversion\": \"/Dash Core:x.x.x/\", (string) the server subversion string\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" + " \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"networks\": [ (array) information per network\n" @@ -432,6 +433,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); if(g_connman) obj.push_back(Pair("localservices", strprintf("%016x", g_connman->GetLocalServices()))); + obj.push_back(Pair("localrelay", fRelayTxes)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if(g_connman) obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)));