@@ -103,7 +103,7 @@ enum BindFlags {
103
103
// The sleep time needs to be small to avoid new sockets stalling
104
104
static const uint64_t SELECT_TIMEOUT_MILLISECONDS = 50 ;
105
105
106
- const std::string NET_MESSAGE_COMMAND_OTHER = " *other*" ;
106
+ const std::string NET_MESSAGE_TYPE_OTHER = " *other*" ;
107
107
108
108
static const uint64_t RANDOMIZER_ID_NETGROUP = 0x6c0edd8036ef4036ULL ; // SHA256("netgroup")[0:8]
109
109
static const uint64_t RANDOMIZER_ID_LOCALHOSTNONCE = 0xd93e69e2bbfa5735ULL ; // SHA256("localhostnonce")[0:8]
@@ -643,12 +643,12 @@ void CNode::CopyStats(CNodeStats& stats)
643
643
X (m_bip152_highbandwidth_from);
644
644
{
645
645
LOCK (cs_vSend);
646
- X (mapSendBytesPerMsgCmd );
646
+ X (mapSendBytesPerMsgType );
647
647
X (nSendBytes);
648
648
}
649
649
{
650
650
LOCK (cs_vRecv);
651
- X (mapRecvBytesPerMsgCmd );
651
+ X (mapRecvBytesPerMsgType );
652
652
X (nRecvBytes);
653
653
}
654
654
X (m_permissionFlags);
@@ -684,19 +684,19 @@ bool CNode::ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete)
684
684
bool reject_message{false };
685
685
CNetMessage msg = m_deserializer->GetMessage (time, reject_message);
686
686
if (reject_message) {
687
- // Message deserialization failed. Drop the message but don't disconnect the peer.
687
+ // Message deserialization failed. Drop the message but don't disconnect the peer.
688
688
// store the size of the corrupt message
689
- mapRecvBytesPerMsgCmd .at (NET_MESSAGE_COMMAND_OTHER ) += msg.m_raw_message_size ;
689
+ mapRecvBytesPerMsgType .at (NET_MESSAGE_TYPE_OTHER ) += msg.m_raw_message_size ;
690
690
continue ;
691
691
}
692
692
693
- // Store received bytes per message command
694
- // to prevent a memory DOS, only allow valid commands
695
- auto i = mapRecvBytesPerMsgCmd .find (msg.m_type );
696
- if (i == mapRecvBytesPerMsgCmd .end ()) {
697
- i = mapRecvBytesPerMsgCmd .find (NET_MESSAGE_COMMAND_OTHER );
693
+ // Store received bytes per message type.
694
+ // To prevent a memory DOS, only allow known message types.
695
+ auto i = mapRecvBytesPerMsgType .find (msg.m_type );
696
+ if (i == mapRecvBytesPerMsgType .end ()) {
697
+ i = mapRecvBytesPerMsgType .find (NET_MESSAGE_TYPE_OTHER );
698
698
}
699
- assert (i != mapRecvBytesPerMsgCmd .end ());
699
+ assert (i != mapRecvBytesPerMsgType .end ());
700
700
i->second += msg.m_raw_message_size ;
701
701
702
702
// push the message to the process queue,
@@ -781,7 +781,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
781
781
// decompose a single CNetMessage from the TransportDeserializer
782
782
CNetMessage msg (std::move (vRecv));
783
783
784
- // store command string, time, and sizes
784
+ // store message type string, time, and sizes
785
785
msg.m_type = hdr.GetCommand ();
786
786
msg.m_time = time;
787
787
msg.m_message_size = hdr.nMessageSize ;
@@ -792,7 +792,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
792
792
// We just received a message off the wire, harvest entropy from the time (and the message checksum)
793
793
RandAddEvent (ReadLE32 (hash.begin ()));
794
794
795
- // Check checksum and header command string
795
+ // Check checksum and header message type string
796
796
if (memcmp (hash.begin (), hdr.pchChecksum , CMessageHeader::CHECKSUM_SIZE) != 0 ) {
797
797
LogPrint (BCLog::NET, " Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n " ,
798
798
SanitizeString (msg.m_type ), msg.m_message_size ,
@@ -3053,8 +3053,8 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, std::shared_ptr<Sock> s
3053
3053
if (inbound_onion) assert (conn_type_in == ConnectionType::INBOUND);
3054
3054
3055
3055
for (const std::string &msg : getAllNetMessageTypes ())
3056
- mapRecvBytesPerMsgCmd [msg] = 0 ;
3057
- mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER ] = 0 ;
3056
+ mapRecvBytesPerMsgType [msg] = 0 ;
3057
+ mapRecvBytesPerMsgType[NET_MESSAGE_TYPE_OTHER ] = 0 ;
3058
3058
3059
3059
if (fLogIPs ) {
3060
3060
LogPrint (BCLog::NET, " Added connection to %s peer=%d\n " , m_addr_name, id);
@@ -3100,7 +3100,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
3100
3100
bool optimisticSend (pnode->vSendMsg .empty ());
3101
3101
3102
3102
// log total amount of bytes per message type
3103
- pnode->mapSendBytesPerMsgCmd [msg.m_type ] += nTotalSize;
3103
+ pnode->mapSendBytesPerMsgType [msg.m_type ] += nTotalSize;
3104
3104
pnode->nSendSize += nTotalSize;
3105
3105
3106
3106
if (pnode->nSendSize > nSendBufferMaxSize) pnode->fPauseSend = true ;
0 commit comments