mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Merge #18533: scripted-diff: Replace strCommand with msg_type
7777e3624f
scripted-diff: Replace strCommand with msg_type (MarcoFalke) Pull request description: Receiving a message is not a command, but simply a message of some type ACKs for top commit: promag: ACK7777e3624f
. naumenkogs: ACK7777e36
practicalswift: ACK7777e3624f
-- I've always thought the `strCommand` name is confusing :) theStack: ACK7777e36
Tree-SHA512: 662bac579064c621191916274314b85111cfb4df488f00893ceb16def1c47af4b2a0f34cd7349722099b5a9d23160edb8eb999841f1d64af3e0da02e4870b4bf
This commit is contained in:
commit
4c59236376
2 changed files with 36 additions and 36 deletions
|
@ -1911,9 +1911,9 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CTxMemPool& mempool, CConnman* connman, BanMan* banman, const std::atomic<bool>& interruptMsgProc)
|
bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CTxMemPool& mempool, CConnman* connman, BanMan* banman, const std::atomic<bool>& interruptMsgProc)
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId());
|
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(msg_type), vRecv.size(), pfrom->GetId());
|
||||||
if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0)
|
if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0)
|
||||||
{
|
{
|
||||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||||
|
@ -1922,8 +1922,8 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
|
|
||||||
|
|
||||||
if (!(pfrom->GetLocalServices() & NODE_BLOOM) &&
|
if (!(pfrom->GetLocalServices() & NODE_BLOOM) &&
|
||||||
(strCommand == NetMsgType::FILTERLOAD ||
|
(msg_type == NetMsgType::FILTERLOAD ||
|
||||||
strCommand == NetMsgType::FILTERADD))
|
msg_type == NetMsgType::FILTERADD))
|
||||||
{
|
{
|
||||||
if (pfrom->nVersion >= NO_BLOOM_VERSION) {
|
if (pfrom->nVersion >= NO_BLOOM_VERSION) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
@ -1935,7 +1935,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::VERSION) {
|
if (msg_type == NetMsgType::VERSION) {
|
||||||
// Each connection can only send one version message
|
// Each connection can only send one version message
|
||||||
if (pfrom->nVersion != 0)
|
if (pfrom->nVersion != 0)
|
||||||
{
|
{
|
||||||
|
@ -2107,7 +2107,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
// At this point, the outgoing message serialization version can't change.
|
// At this point, the outgoing message serialization version can't change.
|
||||||
const CNetMsgMaker msgMaker(pfrom->GetSendVersion());
|
const CNetMsgMaker msgMaker(pfrom->GetSendVersion());
|
||||||
|
|
||||||
if (strCommand == NetMsgType::VERACK)
|
if (msg_type == NetMsgType::VERACK)
|
||||||
{
|
{
|
||||||
pfrom->SetRecvVersion(std::min(pfrom->nVersion.load(), PROTOCOL_VERSION));
|
pfrom->SetRecvVersion(std::min(pfrom->nVersion.load(), PROTOCOL_VERSION));
|
||||||
|
|
||||||
|
@ -2152,7 +2152,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::ADDR) {
|
if (msg_type == NetMsgType::ADDR) {
|
||||||
std::vector<CAddress> vAddr;
|
std::vector<CAddress> vAddr;
|
||||||
vRecv >> vAddr;
|
vRecv >> vAddr;
|
||||||
|
|
||||||
|
@ -2206,13 +2206,13 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::SENDHEADERS) {
|
if (msg_type == NetMsgType::SENDHEADERS) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
State(pfrom->GetId())->fPreferHeaders = true;
|
State(pfrom->GetId())->fPreferHeaders = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::SENDCMPCT) {
|
if (msg_type == NetMsgType::SENDCMPCT) {
|
||||||
bool fAnnounceUsingCMPCTBLOCK = false;
|
bool fAnnounceUsingCMPCTBLOCK = false;
|
||||||
uint64_t nCMPCTBLOCKVersion = 0;
|
uint64_t nCMPCTBLOCKVersion = 0;
|
||||||
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
|
vRecv >> fAnnounceUsingCMPCTBLOCK >> nCMPCTBLOCKVersion;
|
||||||
|
@ -2235,7 +2235,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::INV) {
|
if (msg_type == NetMsgType::INV) {
|
||||||
std::vector<CInv> vInv;
|
std::vector<CInv> vInv;
|
||||||
vRecv >> vInv;
|
vRecv >> vInv;
|
||||||
if (vInv.size() > MAX_INV_SZ)
|
if (vInv.size() > MAX_INV_SZ)
|
||||||
|
@ -2297,7 +2297,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::GETDATA) {
|
if (msg_type == NetMsgType::GETDATA) {
|
||||||
std::vector<CInv> vInv;
|
std::vector<CInv> vInv;
|
||||||
vRecv >> vInv;
|
vRecv >> vInv;
|
||||||
if (vInv.size() > MAX_INV_SZ)
|
if (vInv.size() > MAX_INV_SZ)
|
||||||
|
@ -2318,7 +2318,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::GETBLOCKS) {
|
if (msg_type == NetMsgType::GETBLOCKS) {
|
||||||
CBlockLocator locator;
|
CBlockLocator locator;
|
||||||
uint256 hashStop;
|
uint256 hashStop;
|
||||||
vRecv >> locator >> hashStop;
|
vRecv >> locator >> hashStop;
|
||||||
|
@ -2386,7 +2386,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::GETBLOCKTXN) {
|
if (msg_type == NetMsgType::GETBLOCKTXN) {
|
||||||
BlockTransactionsRequest req;
|
BlockTransactionsRequest req;
|
||||||
vRecv >> req;
|
vRecv >> req;
|
||||||
|
|
||||||
|
@ -2435,7 +2435,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::GETHEADERS) {
|
if (msg_type == NetMsgType::GETHEADERS) {
|
||||||
CBlockLocator locator;
|
CBlockLocator locator;
|
||||||
uint256 hashStop;
|
uint256 hashStop;
|
||||||
vRecv >> locator >> hashStop;
|
vRecv >> locator >> hashStop;
|
||||||
|
@ -2502,7 +2502,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::TX) {
|
if (msg_type == 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 whitelistrelay is off
|
// We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off
|
||||||
// or if this peer is supposed to be a block-relay-only peer
|
// or if this peer is supposed to be a block-relay-only peer
|
||||||
|
@ -2644,7 +2644,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::CMPCTBLOCK)
|
if (msg_type == NetMsgType::CMPCTBLOCK)
|
||||||
{
|
{
|
||||||
// Ignore cmpctblock received while importing
|
// Ignore cmpctblock received while importing
|
||||||
if (fImporting || fReindex) {
|
if (fImporting || fReindex) {
|
||||||
|
@ -2865,7 +2865,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::BLOCKTXN)
|
if (msg_type == NetMsgType::BLOCKTXN)
|
||||||
{
|
{
|
||||||
// Ignore blocktxn received while importing
|
// Ignore blocktxn received while importing
|
||||||
if (fImporting || fReindex) {
|
if (fImporting || fReindex) {
|
||||||
|
@ -2947,7 +2947,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::HEADERS)
|
if (msg_type == NetMsgType::HEADERS)
|
||||||
{
|
{
|
||||||
// Ignore headers received while importing
|
// Ignore headers received while importing
|
||||||
if (fImporting || fReindex) {
|
if (fImporting || fReindex) {
|
||||||
|
@ -2973,7 +2973,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return ProcessHeadersMessage(pfrom, connman, mempool, headers, chainparams, /*via_compact_block=*/false);
|
return ProcessHeadersMessage(pfrom, connman, mempool, headers, chainparams, /*via_compact_block=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::BLOCK)
|
if (msg_type == NetMsgType::BLOCK)
|
||||||
{
|
{
|
||||||
// Ignore block received while importing
|
// Ignore block received while importing
|
||||||
if (fImporting || fReindex) {
|
if (fImporting || fReindex) {
|
||||||
|
@ -3009,7 +3009,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::GETADDR) {
|
if (msg_type == NetMsgType::GETADDR) {
|
||||||
// This asymmetric behavior for inbound and outbound connections was introduced
|
// This asymmetric behavior for inbound and outbound connections was introduced
|
||||||
// to prevent a fingerprinting attack: an attacker can send specific fake addresses
|
// to prevent a fingerprinting attack: an attacker can send specific fake addresses
|
||||||
// to users' AddrMan and later request them by sending getaddr messages.
|
// to users' AddrMan and later request them by sending getaddr messages.
|
||||||
|
@ -3043,7 +3043,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::MEMPOOL) {
|
if (msg_type == NetMsgType::MEMPOOL) {
|
||||||
if (!(pfrom->GetLocalServices() & NODE_BLOOM) && !pfrom->HasPermission(PF_MEMPOOL))
|
if (!(pfrom->GetLocalServices() & NODE_BLOOM) && !pfrom->HasPermission(PF_MEMPOOL))
|
||||||
{
|
{
|
||||||
if (!pfrom->HasPermission(PF_NOBAN))
|
if (!pfrom->HasPermission(PF_NOBAN))
|
||||||
|
@ -3071,7 +3071,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::PING) {
|
if (msg_type == NetMsgType::PING) {
|
||||||
if (pfrom->nVersion > BIP0031_VERSION)
|
if (pfrom->nVersion > BIP0031_VERSION)
|
||||||
{
|
{
|
||||||
uint64_t nonce = 0;
|
uint64_t nonce = 0;
|
||||||
|
@ -3092,7 +3092,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::PONG) {
|
if (msg_type == NetMsgType::PONG) {
|
||||||
int64_t pingUsecEnd = nTimeReceived;
|
int64_t pingUsecEnd = nTimeReceived;
|
||||||
uint64_t nonce = 0;
|
uint64_t nonce = 0;
|
||||||
size_t nAvail = vRecv.in_avail();
|
size_t nAvail = vRecv.in_avail();
|
||||||
|
@ -3148,7 +3148,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::FILTERLOAD) {
|
if (msg_type == NetMsgType::FILTERLOAD) {
|
||||||
CBloomFilter filter;
|
CBloomFilter filter;
|
||||||
vRecv >> filter;
|
vRecv >> filter;
|
||||||
|
|
||||||
|
@ -3168,7 +3168,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::FILTERADD) {
|
if (msg_type == NetMsgType::FILTERADD) {
|
||||||
std::vector<unsigned char> vData;
|
std::vector<unsigned char> vData;
|
||||||
vRecv >> vData;
|
vRecv >> vData;
|
||||||
|
|
||||||
|
@ -3192,7 +3192,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::FILTERCLEAR) {
|
if (msg_type == NetMsgType::FILTERCLEAR) {
|
||||||
if (pfrom->m_tx_relay == nullptr) {
|
if (pfrom->m_tx_relay == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3204,7 +3204,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::FEEFILTER) {
|
if (msg_type == NetMsgType::FEEFILTER) {
|
||||||
CAmount newFeeFilter = 0;
|
CAmount newFeeFilter = 0;
|
||||||
vRecv >> newFeeFilter;
|
vRecv >> newFeeFilter;
|
||||||
if (MoneyRange(newFeeFilter)) {
|
if (MoneyRange(newFeeFilter)) {
|
||||||
|
@ -3217,7 +3217,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == NetMsgType::NOTFOUND) {
|
if (msg_type == NetMsgType::NOTFOUND) {
|
||||||
// Remove the NOTFOUND transactions from the peer
|
// Remove the NOTFOUND transactions from the peer
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CNodeState *state = State(pfrom->GetId());
|
CNodeState *state = State(pfrom->GetId());
|
||||||
|
@ -3243,7 +3243,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vR
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore unknown commands for extensibility
|
// Ignore unknown commands for extensibility
|
||||||
LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->GetId());
|
LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(msg_type), pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3338,7 +3338,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||||
LogPrint(BCLog::NET, "PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(msg.m_command), pfrom->GetId());
|
LogPrint(BCLog::NET, "PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(msg.m_command), pfrom->GetId());
|
||||||
return fMoreWork;
|
return fMoreWork;
|
||||||
}
|
}
|
||||||
const std::string& strCommand = msg.m_command;
|
const std::string& msg_type = msg.m_command;
|
||||||
|
|
||||||
// Message size
|
// Message size
|
||||||
unsigned int nMessageSize = msg.m_message_size;
|
unsigned int nMessageSize = msg.m_message_size;
|
||||||
|
@ -3348,7 +3348,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||||
if (!msg.m_valid_checksum)
|
if (!msg.m_valid_checksum)
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): CHECKSUM ERROR peer=%d\n", __func__,
|
LogPrint(BCLog::NET, "%s(%s, %u bytes): CHECKSUM ERROR peer=%d\n", __func__,
|
||||||
SanitizeString(strCommand), nMessageSize, pfrom->GetId());
|
SanitizeString(msg_type), nMessageSize, pfrom->GetId());
|
||||||
return fMoreWork;
|
return fMoreWork;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3356,19 +3356,19 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
|
||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.m_time, chainparams, m_mempool, connman, m_banman, interruptMsgProc);
|
fRet = ProcessMessage(pfrom, msg_type, vRecv, msg.m_time, chainparams, m_mempool, connman, m_banman, interruptMsgProc);
|
||||||
if (interruptMsgProc)
|
if (interruptMsgProc)
|
||||||
return false;
|
return false;
|
||||||
if (!pfrom->vRecvGetData.empty())
|
if (!pfrom->vRecvGetData.empty())
|
||||||
fMoreWork = true;
|
fMoreWork = true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what(), typeid(e).name());
|
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(msg_type), nMessageSize, e.what(), typeid(e).name());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", __func__, SanitizeString(strCommand), nMessageSize);
|
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", __func__, SanitizeString(msg_type), nMessageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fRet) {
|
if (!fRet) {
|
||||||
LogPrint(BCLog::NET, "%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->GetId());
|
LogPrint(BCLog::NET, "%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(msg_type), nMessageSize, pfrom->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
bool ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CTxMemPool& mempool, CConnman* connman, BanMan* banman, const std::atomic<bool>& interruptMsgProc);
|
bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CTxMemPool& mempool, CConnman* connman, BanMan* banman, const std::atomic<bool>& interruptMsgProc);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue