Skip to content

Commit aa114b1

Browse files
committed
[net_processing] Move SendBlockTransactions into PeerManager
1 parent 3115e00 commit aa114b1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ static uint32_t GetFetchFlags(const CNode& pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_ma
18281828
return nFetchFlags;
18291829
}
18301830

1831-
inline void static SendBlockTransactions(const CBlock& block, const BlockTransactionsRequest& req, CNode& pfrom, CConnman& connman) {
1831+
void PeerManager::SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req) {
18321832
BlockTransactions resp(req);
18331833
for (size_t i = 0; i < req.indexes.size(); i++) {
18341834
if (req.indexes[i] >= block.vtx.size()) {
@@ -1840,7 +1840,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
18401840
LOCK(cs_main);
18411841
const CNetMsgMaker msgMaker(pfrom.GetSendVersion());
18421842
int nSendFlags = State(pfrom.GetId())->fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
1843-
connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp));
1843+
m_connman.PushMessage(&pfrom, msgMaker.Make(nSendFlags, NetMsgType::BLOCKTXN, resp));
18441844
}
18451845

18461846
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
28452845
// Unlock cs_most_recent_block to avoid cs_main lock inversion
28462846
}
28472847
if (recent_block) {
2848-
SendBlockTransactions(*recent_block, req, pfrom, m_connman);
2848+
SendBlockTransactions(pfrom, *recent_block, req);
28492849
return;
28502850
}
28512851

@@ -2878,7 +2878,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
28782878
bool ret = ReadBlockFromDisk(block, pindex, m_chainparams.GetConsensus());
28792879
assert(ret);
28802880

2881-
SendBlockTransactions(block, req, pfrom, m_connman);
2881+
SendBlockTransactions(pfrom, block, req);
28822882
return;
28832883
}
28842884

src/net_processing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <sync.h>
1212
#include <validationinterface.h>
1313

14+
class BlockTransactionsRequest;
1415
class BlockValidationState;
1516
class CBlockHeader;
1617
class CChainParams;
@@ -118,6 +119,8 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
118119
/** Process a single headers message from a peer. */
119120
void ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHeader>& headers, bool via_compact_block);
120121

122+
void SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req);
123+
121124
const CChainParams& m_chainparams;
122125
CConnman& m_connman;
123126
/** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */

0 commit comments

Comments
 (0)