Skip to content

Commit 62948ca

Browse files
author
MarcoFalke
committed
Merge #18937: refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg
51e9393 refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg (Sebastian Falbesoner) Pull request description: Follow-up PR for #18533 -- another small step towards getting rid of the confusing "command" terminology. Also see PR #18610 which tackled the functional tests. ACKs for top commit: MarcoFalke: ACK 51e9393 Tree-SHA512: bb6f05a7be6823d5c4eab1d05b31fee944e700946827ad9425d59a3957fd879776c88c606319cbe9832d9451b275baedf913b71429ea3e01e4e82bf2d419e819
2 parents c940c1a + 51e9393 commit 62948ca

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/net.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ void V1TransportSerializer::prepareForTransport(CSerializedNetMsg& msg, std::vec
737737
uint256 hash = Hash(msg.data.begin(), msg.data.end());
738738

739739
// create header
740-
CMessageHeader hdr(Params().MessageStart(), msg.command.c_str(), msg.data.size());
740+
CMessageHeader hdr(Params().MessageStart(), msg.m_type.c_str(), msg.data.size());
741741
memcpy(hdr.pchChecksum, hash.begin(), CMessageHeader::CHECKSUM_SIZE);
742742

743743
// serialize header
@@ -2794,7 +2794,7 @@ bool CConnman::NodeFullyConnected(const CNode* pnode)
27942794
void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
27952795
{
27962796
size_t nMessageSize = msg.data.size();
2797-
LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", SanitizeString(msg.command), nMessageSize, pnode->GetId());
2797+
LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", SanitizeString(msg.m_type), nMessageSize, pnode->GetId());
27982798

27992799
// make sure we use the appropriate network transport format
28002800
std::vector<unsigned char> serializedHeader;
@@ -2806,8 +2806,8 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
28062806
LOCK(pnode->cs_vSend);
28072807
bool optimisticSend(pnode->vSendMsg.empty());
28082808

2809-
//log total amount of bytes per command
2810-
pnode->mapSendBytesPerMsgCmd[msg.command] += nTotalSize;
2809+
//log total amount of bytes per message type
2810+
pnode->mapSendBytesPerMsgCmd[msg.m_type] += nTotalSize;
28112811
pnode->nSendSize += nTotalSize;
28122812

28132813
if (pnode->nSendSize > nSendBufferMaxSize)

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct CSerializedNetMsg
110110
CSerializedNetMsg& operator=(const CSerializedNetMsg&) = delete;
111111

112112
std::vector<unsigned char> data;
113-
std::string command;
113+
std::string m_type;
114114
};
115115

116116

src/netmessagemaker.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ class CNetMsgMaker
1515
explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}
1616

1717
template <typename... Args>
18-
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const
18+
CSerializedNetMsg Make(int nFlags, std::string msg_type, Args&&... args) const
1919
{
2020
CSerializedNetMsg msg;
21-
msg.command = std::move(sCommand);
21+
msg.m_type = std::move(msg_type);
2222
CVectorWriter{ SER_NETWORK, nFlags | nVersion, msg.data, 0, std::forward<Args>(args)... };
2323
return msg;
2424
}
2525

2626
template <typename... Args>
27-
CSerializedNetMsg Make(std::string sCommand, Args&&... args) const
27+
CSerializedNetMsg Make(std::string msg_type, Args&&... args) const
2828
{
29-
return Make(0, std::move(sCommand), std::forward<Args>(args)...);
29+
return Make(0, std::move(msg_type), std::forward<Args>(args)...);
3030
}
3131

3232
private:

src/test/fuzz/process_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
6262
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
6363

6464
CSerializedNetMsg net_msg;
65-
net_msg.command = random_message_type;
65+
net_msg.m_type = random_message_type;
6666
net_msg.data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
6767

6868
CNode& random_node = *peers.at(fuzzed_data_provider.ConsumeIntegralInRange<int>(0, peers.size() - 1));

0 commit comments

Comments
 (0)