Changeset View
Changeset View
Standalone View
Standalone View
src/blockencodings.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | ReadStatus PartiallyDownloadedBlock::InitData( | ||||
if (shorttxids.size() != cmpctblock.shorttxids.size()) { | if (shorttxids.size() != cmpctblock.shorttxids.size()) { | ||||
// Short ID collision | // Short ID collision | ||||
return READ_STATUS_FAILED; | return READ_STATUS_FAILED; | ||||
} | } | ||||
std::vector<bool> have_txn(txns_available.size()); | std::vector<bool> have_txn(txns_available.size()); | ||||
{ | { | ||||
LOCK(pool->cs); | LOCK(pool->cs); | ||||
const std::vector<std::pair<TxHash, CTxMemPool::txiter>> &vTxHashes = | for (size_t i = 0; i < pool->vTxHashes.size(); i++) { | ||||
pool->vTxHashes; | uint64_t shortid = cmpctblock.GetShortID(pool->vTxHashes[i].first); | ||||
for (auto txHash : vTxHashes) { | |||||
uint64_t shortid = cmpctblock.GetShortID(txHash.first); | |||||
std::unordered_map<uint64_t, uint32_t>::iterator idit = | std::unordered_map<uint64_t, uint32_t>::iterator idit = | ||||
shorttxids.find(shortid); | shorttxids.find(shortid); | ||||
if (idit != shorttxids.end()) { | if (idit != shorttxids.end()) { | ||||
if (!have_txn[idit->second]) { | if (!have_txn[idit->second]) { | ||||
txns_available[idit->second] = txHash.second->GetSharedTx(); | txns_available[idit->second] = | ||||
pool->vTxHashes[i].second->GetSharedTx(); | |||||
have_txn[idit->second] = true; | have_txn[idit->second] = true; | ||||
mempool_count++; | mempool_count++; | ||||
} else { | } else { | ||||
// If we find two mempool txn that match the short id, just | // If we find two mempool txn that match the short id, just | ||||
// request it. This should be rare enough that the extra | // request it. This should be rare enough that the extra | ||||
// bandwidth doesn't matter, but eating a round-trip due to | // bandwidth doesn't matter, but eating a round-trip due to | ||||
// FillBlock failure would be annoying. | // FillBlock failure would be annoying. | ||||
if (txns_available[idit->second]) { | if (txns_available[idit->second]) { | ||||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |