mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
[net_processing] Move SendBlockTransactions into PeerManager
This commit is contained in:
parent
3115e00f75
commit
aa114b1c9b
@ -1828,7 +1828,7 @@ static uint32_t GetFetchFlags(const CNode& pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_ma
|
|||||||
return nFetchFlags;
|
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);
|
BlockTransactions resp(req);
|
||||||
for (size_t i = 0; i < req.indexes.size(); i++) {
|
for (size_t i = 0; i < req.indexes.size(); i++) {
|
||||||
if (req.indexes[i] >= block.vtx.size()) {
|
if (req.indexes[i] >= block.vtx.size()) {
|
||||||
@ -1840,7 +1840,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CNetMsgMaker msgMaker(pfrom.GetSendVersion());
|
const CNetMsgMaker msgMaker(pfrom.GetSendVersion());
|
||||||
int nSendFlags = State(pfrom.GetId())->fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
|
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)
|
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
|
// Unlock cs_most_recent_block to avoid cs_main lock inversion
|
||||||
}
|
}
|
||||||
if (recent_block) {
|
if (recent_block) {
|
||||||
SendBlockTransactions(*recent_block, req, pfrom, m_connman);
|
SendBlockTransactions(pfrom, *recent_block, req);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2878,7 +2878,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|||||||
bool ret = ReadBlockFromDisk(block, pindex, m_chainparams.GetConsensus());
|
bool ret = ReadBlockFromDisk(block, pindex, m_chainparams.GetConsensus());
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
SendBlockTransactions(block, req, pfrom, m_connman);
|
SendBlockTransactions(pfrom, block, req);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
|
||||||
|
class BlockTransactionsRequest;
|
||||||
class BlockValidationState;
|
class BlockValidationState;
|
||||||
class CBlockHeader;
|
class CBlockHeader;
|
||||||
class CChainParams;
|
class CChainParams;
|
||||||
@ -118,6 +119,8 @@ private:
|
|||||||
/** Process a single headers message from a peer. */
|
/** Process a single headers message from a peer. */
|
||||||
void ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHeader>& headers, bool via_compact_block);
|
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;
|
const CChainParams& m_chainparams;
|
||||||
CConnman& m_connman;
|
CConnman& m_connman;
|
||||||
/** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */
|
/** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */
|
||||||
|
Loading…
Reference in New Issue
Block a user