diff options
author | John Newbery <john@johnnewbery.com> | 2020-08-24 16:45:46 +0100 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2020-09-07 11:16:12 +0100 |
commit | aa114b1c9b06c2bd3ed936bbb9fb32b31f75bdb2 (patch) | |
tree | 368ee9db84b886308c4932b09d776ee80225968b /src | |
parent | 3115e00f75b41d9765dcbb376e367b25f61a1d58 (diff) |
[net_processing] Move SendBlockTransactions into PeerManager
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 8 | ||||
-rw-r--r-- | src/net_processing.h | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c99b73bd31..443e7c6eea 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1828,7 +1828,7 @@ static uint32_t GetFetchFlags(const CNode& pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_ma return nFetchFlags; } -inline void static SendBlockTransactions(const CBlock& block, const BlockTransactionsRequest& req, CNode& pfrom, CConnman& connman) { +void PeerManager::SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req) { BlockTransactions resp(req); for (size_t i = 0; i < req.indexes.size(); i++) { if (req.indexes[i] >= block.vtx.size()) { @@ -1840,7 +1840,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac LOCK(cs_main); 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)); + m_connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp)); } void PeerManager::ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHeader>& headers, bool via_compact_block) @@ -2845,7 +2845,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat // Unlock cs_most_recent_block to avoid cs_main lock inversion } if (recent_block) { - SendBlockTransactions(*recent_block, req, pfrom, m_connman); + SendBlockTransactions(pfrom, *recent_block, req); return; } @@ -2878,7 +2878,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat bool ret = ReadBlockFromDisk(block, pindex, m_chainparams.GetConsensus()); assert(ret); - SendBlockTransactions(block, req, pfrom, m_connman); + SendBlockTransactions(pfrom, block, req); return; } diff --git a/src/net_processing.h b/src/net_processing.h index 4f350630f1..c89fdb601b 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -11,6 +11,7 @@ #include <sync.h> #include <validationinterface.h> +class BlockTransactionsRequest; class BlockValidationState; class CBlockHeader; class CChainParams; @@ -118,6 +119,8 @@ private: /** Process a single headers message from a peer. */ void ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHeader>& headers, bool via_compact_block); + void SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req); + const CChainParams& m_chainparams; CConnman& m_connman; /** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */ |