From d16b7dbcb547aebb1740dd9b90c53d4de9f85da1 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Mon, 30 Mar 2020 10:37:13 +0200 Subject: [PATCH] Implement hidden "-pushversion" parameter for PoSe testing --- src/net_processing.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index af64b2a135..86926a7ca0 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -304,6 +304,8 @@ void UpdatePreferredDownload(CNode* node, CNodeState* state) void PushNodeVersion(CNode *pnode, CConnman* connman, int64_t nTime) { + const auto& params = Params(); + ServiceFlags nLocalNodeServices = pnode->GetLocalServices(); uint64_t nonce = pnode->GetLocalNonce(); int nNodeStartingHeight = pnode->GetMyStartingHeight(); @@ -320,13 +322,18 @@ void PushNodeVersion(CNode *pnode, CConnman* connman, int64_t nTime) pnode->sentMNAuthChallenge = mnauthChallenge; } - connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe, + int nProtocolVersion = PROTOCOL_VERSION; + if (params.NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) { + nProtocolVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION); + } + + connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, nProtocolVersion, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe, nonce, strSubVersion, nNodeStartingHeight, ::fRelayTxes, mnauthChallenge, pnode->fMasternode)); if (fLogIPs) { - LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), addrYou.ToString(), nodeid); + LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", nProtocolVersion, nNodeStartingHeight, addrMe.ToString(), addrYou.ToString(), nodeid); } else { - LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), nodeid); + LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, peer=%d\n", nProtocolVersion, nNodeStartingHeight, addrMe.ToString(), nodeid); } }