This commit is contained in:
jl777
2017-02-03 16:10:18 +02:00
parent ad70a28f2f
commit 13931733fb

View File

@@ -4343,31 +4343,35 @@ void static ProcessGetData(CNode* pfrom)
// Send block from disk // Send block from disk
CBlock block; CBlock block;
if (!ReadBlockFromDisk(block, (*mi).second)) if (!ReadBlockFromDisk(block, (*mi).second))
assert(!"cannot load block from disk");
if (inv.type == MSG_BLOCK)
pfrom->PushMessage("block", block);
else // MSG_FILTERED_BLOCK)
{ {
LOCK(pfrom->cs_filter); assert(!"cannot load block from disk");
if (pfrom->pfilter) }
else
{
if (inv.type == MSG_BLOCK)
pfrom->PushMessage("block", block);
else // MSG_FILTERED_BLOCK)
{ {
CMerkleBlock merkleBlock(block, *pfrom->pfilter); LOCK(pfrom->cs_filter);
pfrom->PushMessage("merkleblock", merkleBlock); if (pfrom->pfilter)
// CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see {
// This avoids hurting performance by pointlessly requiring a round-trip CMerkleBlock merkleBlock(block, *pfrom->pfilter);
// Note that there is currently no way for a node to request any single transactions we didn't send here - pfrom->PushMessage("merkleblock", merkleBlock);
// they must either disconnect and retry or request the full block. // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
// Thus, the protocol spec specified allows for us to provide duplicate txn here, // This avoids hurting performance by pointlessly requiring a round-trip
// however we MUST always provide at least what the remote peer needs // Note that there is currently no way for a node to request any single transactions we didn't send here -
typedef std::pair<unsigned int, uint256> PairType; // they must either disconnect and retry or request the full block.
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn) // Thus, the protocol spec specified allows for us to provide duplicate txn here,
// however we MUST always provide at least what the remote peer needs
typedef std::pair<unsigned int, uint256> PairType;
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second))) if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second)))
pfrom->PushMessage("tx", block.vtx[pair.first]); pfrom->PushMessage("tx", block.vtx[pair.first]);
} }
// else // else
// no response // no response
}
} }
// Trigger the peer node to send a getblocks request for the next batch of inventory // Trigger the peer node to send a getblocks request for the next batch of inventory
if (inv.hash == pfrom->hashContinue) if (inv.hash == pfrom->hashContinue)
{ {