Skip to content

Commit fc7f2ff

Browse files
committed
Net: Make CNetMsgMaker more const
1 parent d45955f commit fc7f2ff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ static uint256 most_recent_block_hash;
778778

779779
void PeerLogicValidation::NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) {
780780
std::shared_ptr<const CBlockHeaderAndShortTxIDs> pcmpctblock = std::make_shared<const CBlockHeaderAndShortTxIDs> (*pblock, true);
781-
CNetMsgMaker msgMaker(PROTOCOL_VERSION);
781+
const CNetMsgMaker msgMaker(PROTOCOL_VERSION);
782782

783783
LOCK(cs_main);
784784

@@ -960,7 +960,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
960960
{
961961
std::deque<CInv>::iterator it = pfrom->vRecvGetData.begin();
962962
std::vector<CInv> vNotFound;
963-
CNetMsgMaker msgMaker(pfrom->GetSendVersion());
963+
const CNetMsgMaker msgMaker(pfrom->GetSendVersion());
964964
LOCK(cs_main);
965965

966966
while (it != pfrom->vRecvGetData.end()) {
@@ -1153,7 +1153,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
11531153
resp.txn[i] = block.vtx[req.indexes[i]];
11541154
}
11551155
LOCK(cs_main);
1156-
CNetMsgMaker msgMaker(pfrom->GetSendVersion());
1156+
const CNetMsgMaker msgMaker(pfrom->GetSendVersion());
11571157
int nSendFlags = State(pfrom->GetId())->fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
11581158
connman.PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp));
11591159
}
@@ -1346,7 +1346,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
13461346
}
13471347

13481348
// At this point, the outgoing message serialization version can't change.
1349-
CNetMsgMaker msgMaker(pfrom->GetSendVersion());
1349+
const CNetMsgMaker msgMaker(pfrom->GetSendVersion());
13501350

13511351
if (strCommand == NetMsgType::VERACK)
13521352
{
@@ -2721,7 +2721,7 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
27212721
return true;
27222722

27232723
// If we get here, the outgoing message serialization version is set and can't change.
2724-
CNetMsgMaker msgMaker(pto->GetSendVersion());
2724+
const CNetMsgMaker msgMaker(pto->GetSendVersion());
27252725

27262726
//
27272727
// Message: ping

src/netmessagemaker.h

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

1717
template <typename... Args>
18-
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args)
18+
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const
1919
{
2020
CSerializedNetMsg msg;
2121
msg.command = std::move(sCommand);
@@ -24,7 +24,7 @@ class CNetMsgMaker
2424
}
2525

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

0 commit comments

Comments
 (0)