Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,049 Lines • ▼ Show 20 Lines | if (send && pindex->nStatus.hasData()) { | ||||
cmpctblock)); | cmpctblock)); | ||||
} else { | } else { | ||||
connman.PushMessage( | connman.PushMessage( | ||||
&pfrom, | &pfrom, | ||||
msgMaker.Make(nSendFlags, NetMsgType::BLOCK, *pblock)); | msgMaker.Make(nSendFlags, NetMsgType::BLOCK, *pblock)); | ||||
} | } | ||||
} | } | ||||
// Trigger the peer node to send a getblocks request for the next batch | { | ||||
// of inventory. | LOCK(peer.m_block_inv_mutex); | ||||
// Trigger the peer node to send a getblocks request for the next | |||||
// batch of inventory. | |||||
if (hash == peer.m_continuation_block) { | if (hash == peer.m_continuation_block) { | ||||
// Send immediately. This must send even if redundant, and | // Send immediately. This must send even if redundant, and | ||||
// we want it right after the last block so they don't wait for | // we want it right after the last block so they don't wait for | ||||
// other stuff first. | // other stuff first. | ||||
std::vector<CInv> vInv; | std::vector<CInv> vInv; | ||||
vInv.push_back( | vInv.push_back( | ||||
CInv(MSG_BLOCK, ::ChainActive().Tip()->GetBlockHash())); | CInv(MSG_BLOCK, ::ChainActive().Tip()->GetBlockHash())); | ||||
connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv)); | connman.PushMessage(&pfrom, | ||||
msgMaker.Make(NetMsgType::INV, vInv)); | |||||
peer.m_continuation_block = BlockHash(); | peer.m_continuation_block = BlockHash(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
//! Determine whether or not a peer can request a transaction, and return it (or | //! Determine whether or not a peer can request a transaction, and return it (or | ||||
//! nullptr if not found or not allowed). | //! nullptr if not found or not allowed). | ||||
static CTransactionRef FindTxForGetData(const CTxMemPool &mempool, | static CTransactionRef FindTxForGetData(const CTxMemPool &mempool, | ||||
const CNode &peer, const TxId &txid, | const CNode &peer, const TxId &txid, | ||||
const std::chrono::seconds mempool_req, | const std::chrono::seconds mempool_req, | ||||
const std::chrono::seconds now) | const std::chrono::seconds now) | ||||
LOCKS_EXCLUDED(cs_main) { | LOCKS_EXCLUDED(cs_main) { | ||||
▲ Show 20 Lines • Show All 1,447 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::GETBLOCKS) { | ||||
WITH_LOCK( | WITH_LOCK( | ||||
peer->m_block_inv_mutex, | peer->m_block_inv_mutex, | ||||
peer->m_blocks_for_inv_relay.push_back(pindex->GetBlockHash())); | peer->m_blocks_for_inv_relay.push_back(pindex->GetBlockHash())); | ||||
if (--nLimit <= 0) { | if (--nLimit <= 0) { | ||||
// When this block is requested, we'll send an inv that'll | // When this block is requested, we'll send an inv that'll | ||||
// trigger the peer to getblocks the next batch of inventory. | // trigger the peer to getblocks the next batch of inventory. | ||||
LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", | LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", | ||||
pindex->nHeight, pindex->GetBlockHash().ToString()); | pindex->nHeight, pindex->GetBlockHash().ToString()); | ||||
WITH_LOCK(peer->m_block_inv_mutex, { | |||||
peer->m_continuation_block = pindex->GetBlockHash(); | peer->m_continuation_block = pindex->GetBlockHash(); | ||||
}); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (msg_type == NetMsgType::GETBLOCKTXN) { | if (msg_type == NetMsgType::GETBLOCKTXN) { | ||||
BlockTransactionsRequest req; | BlockTransactionsRequest req; | ||||
▲ Show 20 Lines • Show All 2,492 Lines • Show Last 20 Lines |