Skip to content

Commit e71c51b

Browse files
shaavantheStack
andcommitted
refactor: rename command -> message type in comments in the src/net* files
Co-authored-by: Sebastian Falbesoner <[email protected]>
1 parent 2b09593 commit e71c51b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -651,14 +651,14 @@ bool CNode::ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete)
651651
bool reject_message{false};
652652
CNetMessage msg = m_deserializer->GetMessage(time, reject_message);
653653
if (reject_message) {
654-
// Message deserialization failed. Drop the message but don't disconnect the peer.
654+
// Message deserialization failed. Drop the message but don't disconnect the peer.
655655
// store the size of the corrupt message
656656
mapRecvBytesPerMsgType.at(NET_MESSAGE_TYPE_OTHER) += msg.m_raw_message_size;
657657
continue;
658658
}
659659

660-
// Store received bytes per message command
661-
// to prevent a memory DOS, only allow valid commands
660+
// Store received bytes per message type.
661+
// To prevent a memory DOS, only allow known message types.
662662
auto i = mapRecvBytesPerMsgType.find(msg.m_type);
663663
if (i == mapRecvBytesPerMsgType.end()) {
664664
i = mapRecvBytesPerMsgType.find(NET_MESSAGE_TYPE_OTHER);
@@ -748,7 +748,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
748748
// decompose a single CNetMessage from the TransportDeserializer
749749
CNetMessage msg(std::move(vRecv));
750750

751-
// store command string, time, and sizes
751+
// store message type string, time, and sizes
752752
msg.m_type = hdr.GetCommand();
753753
msg.m_time = time;
754754
msg.m_message_size = hdr.nMessageSize;
@@ -759,7 +759,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
759759
// We just received a message off the wire, harvest entropy from the time (and the message checksum)
760760
RandAddEvent(ReadLE32(hash.begin()));
761761

762-
// Check checksum and header command string
762+
// Check checksum and header message type string
763763
if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
764764
LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
765765
SanitizeString(msg.m_type), msg.m_message_size,

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ extern Mutex g_maplocalhost_mutex;
234234
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(g_maplocalhost_mutex);
235235

236236
extern const std::string NET_MESSAGE_TYPE_OTHER;
237-
typedef std::map<std::string, uint64_t> mapMsgTypeSize; //command, total bytes
237+
using mapMsgTypeSize = std::map</* message type */ std::string, /* total bytes */ uint64_t>;
238238

239239
class CNodeStats
240240
{
@@ -298,7 +298,7 @@ class CNetMessage {
298298

299299
/** The TransportDeserializer takes care of holding and deserializing the
300300
* network receive buffer. It can deserialize the network buffer into a
301-
* transport protocol agnostic CNetMessage (command & payload)
301+
* transport protocol agnostic CNetMessage (message type & payload)
302302
*/
303303
class TransportDeserializer {
304304
public:

0 commit comments

Comments
 (0)