From fc7f2ffad481870e62ab2f798f941577983c5a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Tue, 31 Jan 2017 22:57:40 +0100 Subject: [PATCH] Net: Make CNetMsgMaker more const --- src/net_processing.cpp | 10 +++++----- src/netmessagemaker.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index b9667eb6c..995779338 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -778,7 +778,7 @@ static uint256 most_recent_block_hash; void PeerLogicValidation::NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr& pblock) { std::shared_ptr pcmpctblock = std::make_shared (*pblock, true); - CNetMsgMaker msgMaker(PROTOCOL_VERSION); + const CNetMsgMaker msgMaker(PROTOCOL_VERSION); LOCK(cs_main); @@ -960,7 +960,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam { std::deque::iterator it = pfrom->vRecvGetData.begin(); std::vector vNotFound; - CNetMsgMaker msgMaker(pfrom->GetSendVersion()); + const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); LOCK(cs_main); while (it != pfrom->vRecvGetData.end()) { @@ -1153,7 +1153,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac resp.txn[i] = block.vtx[req.indexes[i]]; } LOCK(cs_main); - CNetMsgMaker msgMaker(pfrom->GetSendVersion()); + const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); int nSendFlags = State(pfrom->GetId())->fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS; connman.PushMessage(pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp)); } @@ -1346,7 +1346,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR } // At this point, the outgoing message serialization version can't change. - CNetMsgMaker msgMaker(pfrom->GetSendVersion()); + const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); if (strCommand == NetMsgType::VERACK) { @@ -2721,7 +2721,7 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic& interruptMsg return true; // If we get here, the outgoing message serialization version is set and can't change. - CNetMsgMaker msgMaker(pto->GetSendVersion()); + const CNetMsgMaker msgMaker(pto->GetSendVersion()); // // Message: ping diff --git a/src/netmessagemaker.h b/src/netmessagemaker.h index 7167434a1..8e8a6e4a0 100644 --- a/src/netmessagemaker.h +++ b/src/netmessagemaker.h @@ -15,7 +15,7 @@ public: CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){} template - CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) + CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const { CSerializedNetMsg msg; msg.command = std::move(sCommand); @@ -24,7 +24,7 @@ public: } template - CSerializedNetMsg Make(std::string sCommand, Args&&... args) + CSerializedNetMsg Make(std::string sCommand, Args&&... args) const { return Make(0, std::move(sCommand), std::forward(args)...); }