@@ -735,7 +735,7 @@ int V1Transport::readHeader(Span<const uint8_t> msg_bytes)
735
735
736
736
// reject messages larger than MAX_SIZE or MAX_PROTOCOL_MESSAGE_LENGTH
737
737
if (hdr.nMessageSize > MAX_SIZE || hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) {
738
- LogDebug (BCLog::NET, " Header error: Size too large (%s, %u bytes), peer=%d\n " , SanitizeString (hdr.GetCommand ()), hdr.nMessageSize , m_node_id);
738
+ LogDebug (BCLog::NET, " Header error: Size too large (%s, %u bytes), peer=%d\n " , SanitizeString (hdr.GetMessageType ()), hdr.nMessageSize , m_node_id);
739
739
return -1 ;
740
740
}
741
741
@@ -782,7 +782,7 @@ CNetMessage V1Transport::GetReceivedMessage(const std::chrono::microseconds time
782
782
CNetMessage msg (std::move (vRecv));
783
783
784
784
// store message type string, time, and sizes
785
- msg.m_type = hdr.GetCommand ();
785
+ msg.m_type = hdr.GetMessageType ();
786
786
msg.m_time = time ;
787
787
msg.m_message_size = hdr.nMessageSize ;
788
788
msg.m_raw_message_size = hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
@@ -800,9 +800,9 @@ CNetMessage V1Transport::GetReceivedMessage(const std::chrono::microseconds time
800
800
HexStr (hdr.pchChecksum ),
801
801
m_node_id);
802
802
reject_message = true ;
803
- } else if (!hdr.IsCommandValid ()) {
803
+ } else if (!hdr.IsMessageTypeValid ()) {
804
804
LogDebug (BCLog::NET, " Header error: Invalid message type (%s, %u bytes), peer=%d\n " ,
805
- SanitizeString (hdr.GetCommand ()), msg.m_message_size , m_node_id);
805
+ SanitizeString (hdr.GetMessageType ()), msg.m_message_size , m_node_id);
806
806
reject_message = true ;
807
807
}
808
808
@@ -1184,7 +1184,7 @@ bool V2Transport::ProcessReceivedPacketBytes() noexcept
1184
1184
// - 12 bytes of message type
1185
1185
// - payload
1186
1186
static constexpr size_t MAX_CONTENTS_LEN =
1187
- 1 + CMessageHeader::COMMAND_SIZE +
1187
+ 1 + CMessageHeader::MESSAGE_TYPE_SIZE +
1188
1188
std::min<size_t >(MAX_SIZE, MAX_PROTOCOL_MESSAGE_LENGTH);
1189
1189
1190
1190
if (m_recv_buffer.size () == BIP324Cipher::LENGTH_LEN) {
@@ -1399,26 +1399,26 @@ std::optional<std::string> V2Transport::GetMessageType(Span<const uint8_t>& cont
1399
1399
}
1400
1400
}
1401
1401
1402
- if (contents.size () < CMessageHeader::COMMAND_SIZE ) {
1402
+ if (contents.size () < CMessageHeader::MESSAGE_TYPE_SIZE ) {
1403
1403
return std::nullopt; // Long encoding needs 12 message type bytes.
1404
1404
}
1405
1405
1406
1406
size_t msg_type_len{0 };
1407
- while (msg_type_len < CMessageHeader::COMMAND_SIZE && contents[msg_type_len] != 0 ) {
1407
+ while (msg_type_len < CMessageHeader::MESSAGE_TYPE_SIZE && contents[msg_type_len] != 0 ) {
1408
1408
// Verify that message type bytes before the first 0x00 are in range.
1409
1409
if (contents[msg_type_len] < ' ' || contents[msg_type_len] > 0x7F ) {
1410
1410
return {};
1411
1411
}
1412
1412
++msg_type_len;
1413
1413
}
1414
1414
std::string ret{reinterpret_cast <const char *>(contents.data ()), msg_type_len};
1415
- while (msg_type_len < CMessageHeader::COMMAND_SIZE ) {
1415
+ while (msg_type_len < CMessageHeader::MESSAGE_TYPE_SIZE ) {
1416
1416
// Verify that message type bytes after the first 0x00 are also 0x00.
1417
1417
if (contents[msg_type_len] != 0 ) return {};
1418
1418
++msg_type_len;
1419
1419
}
1420
1420
// Strip message type bytes of contents.
1421
- contents = contents.subspan (CMessageHeader::COMMAND_SIZE );
1421
+ contents = contents.subspan (CMessageHeader::MESSAGE_TYPE_SIZE );
1422
1422
return ret;
1423
1423
}
1424
1424
@@ -1470,9 +1470,9 @@ bool V2Transport::SetMessageToSend(CSerializedNetMsg& msg) noexcept
1470
1470
} else {
1471
1471
// Initialize with zeroes, and then write the message type string starting at offset 1.
1472
1472
// This means contents[0] and the unused positions in contents[1..13] remain 0x00.
1473
- contents.resize (1 + CMessageHeader::COMMAND_SIZE + msg.data .size (), 0 );
1473
+ contents.resize (1 + CMessageHeader::MESSAGE_TYPE_SIZE + msg.data .size (), 0 );
1474
1474
std::copy (msg.m_type .begin (), msg.m_type .end (), contents.data () + 1 );
1475
- std::copy (msg.data .begin (), msg.data .end (), contents.begin () + 1 + CMessageHeader::COMMAND_SIZE );
1475
+ std::copy (msg.data .begin (), msg.data .end (), contents.begin () + 1 + CMessageHeader::MESSAGE_TYPE_SIZE );
1476
1476
}
1477
1477
// Construct ciphertext in send buffer.
1478
1478
m_send_buffer.resize (contents.size () + BIP324Cipher::EXPANSION);
@@ -3936,7 +3936,7 @@ static void CaptureMessageToFile(const CAddress& addr,
3936
3936
3937
3937
ser_writedata64 (f, now.count ());
3938
3938
f << Span{msg_type};
3939
- for (auto i = msg_type.length (); i < CMessageHeader::COMMAND_SIZE ; ++i) {
3939
+ for (auto i = msg_type.length (); i < CMessageHeader::MESSAGE_TYPE_SIZE ; ++i) {
3940
3940
f << uint8_t {' \0 ' };
3941
3941
}
3942
3942
uint32_t size = data.size ();
0 commit comments