Backport Bitcoin PR#8049: Expose information on whether transaction relay is enabled in getnetwork
(#1545)
* net: Add fRelayTxes flag Add a fRelayTxes to keep track of the relay transaction flag we send to other peers. * rpc: Add `relaytxes` flag to `getnetworkinfo` Re-work of PR #7841 by dragongem45. Closes #7771.
This commit is contained in:
parent
4942884c71
commit
82851b439c
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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<CNetAddr, LocalServiceInfo> mapLocalHost;
|
||||
static bool vfLimited[NET_MAX] = {};
|
||||
|
@ -470,6 +470,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
|
||||
|
||||
extern bool fDiscover;
|
||||
extern bool fListen;
|
||||
extern bool fRelayTxes;
|
||||
|
||||
extern std::map<CInv, CDataStream> mapRelay;
|
||||
extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
|
||||
|
@ -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)));
|
||||
|
Loading…
Reference in New Issue
Block a user