diff options
author | Matt Corallo <git@bluematt.me> | 2016-06-19 01:31:52 -0700 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2016-06-19 23:06:55 -0700 |
commit | 0d4cb48ef1b916679d9fad9f247a297c85c7fedf (patch) | |
tree | 784ef3d7d9846b744f6f02378b8f4c57b685ef0b /src | |
parent | 811902649d6aaddd886cb39b83aa69adf7b441bd (diff) |
Use vTxHashes to optimize InitData significantly
Diffstat (limited to 'src')
-rw-r--r-- | src/blockencodings.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index 204de45c29..9a0805e400 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -99,11 +99,13 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c std::vector<bool> have_txn(txn_available.size()); LOCK(pool->cs); - for (CTxMemPool::txiter it = pool->mapTx.begin(); it != pool->mapTx.end(); it++) { - std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(cmpctblock.GetShortID(it->GetTx().GetHash())); + const std::vector<std::pair<uint256, CTxMemPool::txiter> >& vTxHashes = pool->vTxHashes; + for (size_t i = 0; i < vTxHashes.size(); i++) { + uint64_t shortid = cmpctblock.GetShortID(vTxHashes[i].first); + std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid); if (idit != shorttxids.end()) { if (!have_txn[idit->second]) { - txn_available[idit->second] = it->GetSharedTx(); + txn_available[idit->second] = vTxHashes[i].second->GetSharedTx(); have_txn[idit->second] = true; mempool_count++; } else { |