Skip to content

Commit 3073a99

Browse files
committed
scripted-diff: Rename CNetMessage::m_command with CNetMessage::m_type
-BEGIN VERIFY SCRIPT- sed -i 's/std::string m_command;/std::string m_type;/g' ./src/net.h sed -i 's/* command and size./* type and size./g' ./src/net.h sed -i 's/msg.m_command/msg.m_type/g' ./src/net.cpp ./src/net_processing.cpp ./src/test/fuzz/p2p_transport_serialization.cpp -END VERIFY SCRIPT-
1 parent 807169e commit 3073a99

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/net.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ bool CNode::ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete)
657657

658658
// Store received bytes per message command
659659
// to prevent a memory DOS, only allow valid commands
660-
auto i = mapRecvBytesPerMsgCmd.find(msg.m_command);
660+
auto i = mapRecvBytesPerMsgCmd.find(msg.m_type);
661661
if (i == mapRecvBytesPerMsgCmd.end()) {
662662
i = mapRecvBytesPerMsgCmd.find(NET_MESSAGE_COMMAND_OTHER);
663663
}
@@ -747,7 +747,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
747747
CNetMessage msg(std::move(vRecv));
748748

749749
// store command string, time, and sizes
750-
msg.m_command = hdr.GetCommand();
750+
msg.m_type = hdr.GetCommand();
751751
msg.m_time = time;
752752
msg.m_message_size = hdr.nMessageSize;
753753
msg.m_raw_message_size = hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
@@ -760,7 +760,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
760760
// Check checksum and header command string
761761
if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
762762
LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
763-
SanitizeString(msg.m_command), msg.m_message_size,
763+
SanitizeString(msg.m_type), msg.m_message_size,
764764
HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)),
765765
HexStr(hdr.pchChecksum),
766766
m_node_id);

src/net.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ class CNodeStats
278278

279279
/** Transport protocol agnostic message container.
280280
* Ideally it should only contain receive time, payload,
281-
* command and size.
281+
* type and size.
282282
*/
283283
class CNetMessage {
284284
public:
285285
CDataStream m_recv; //!< received message data
286286
std::chrono::microseconds m_time{0}; //!< time of message receipt
287287
uint32_t m_message_size{0}; //!< size of the payload
288288
uint32_t m_raw_message_size{0}; //!< used wire size of the message (including header/checksum)
289-
std::string m_command;
289+
std::string m_type;
290290

291291
CNetMessage(CDataStream&& recv_in) : m_recv(std::move(recv_in)) {}
292292

src/net_processing.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4154,17 +4154,17 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
41544154
pfrom->GetId(),
41554155
pfrom->m_addr_name.c_str(),
41564156
pfrom->ConnectionTypeAsString().c_str(),
4157-
msg.m_command.c_str(),
4157+
msg.m_type.c_str(),
41584158
msg.m_recv.size(),
41594159
msg.m_recv.data()
41604160
);
41614161

41624162
if (gArgs.GetBoolArg("-capturemessages", false)) {
4163-
CaptureMessage(pfrom->addr, msg.m_command, MakeUCharSpan(msg.m_recv), /*is_incoming=*/true);
4163+
CaptureMessage(pfrom->addr, msg.m_type, MakeUCharSpan(msg.m_recv), /*is_incoming=*/true);
41644164
}
41654165

41664166
msg.SetVersion(pfrom->GetCommonVersion());
4167-
const std::string& msg_type = msg.m_command;
4167+
const std::string& msg_type = msg.m_type;
41684168

41694169
// Message size
41704170
unsigned int nMessageSize = msg.m_message_size;

src/test/fuzz/p2p_transport_serialization.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serializa
7070
const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
7171
bool reject_message{false};
7272
CNetMessage msg = deserializer.GetMessage(m_time, reject_message);
73-
assert(msg.m_command.size() <= CMessageHeader::COMMAND_SIZE);
73+
assert(msg.m_type.size() <= CMessageHeader::COMMAND_SIZE);
7474
assert(msg.m_raw_message_size <= mutable_msg_bytes.size());
7575
assert(msg.m_raw_message_size == CMessageHeader::HEADER_SIZE + msg.m_message_size);
7676
assert(msg.m_time == m_time);
7777

7878
std::vector<unsigned char> header;
79-
auto msg2 = CNetMsgMaker{msg.m_recv.GetVersion()}.Make(msg.m_command, MakeUCharSpan(msg.m_recv));
79+
auto msg2 = CNetMsgMaker{msg.m_recv.GetVersion()}.Make(msg.m_type, MakeUCharSpan(msg.m_recv));
8080
serializer.prepareForTransport(msg2, header);
8181
}
8282
}

0 commit comments

Comments
 (0)