Skip to content

Commit 0d4cb48

Browse files
committed
Use vTxHashes to optimize InitData significantly
1 parent 8119026 commit 0d4cb48

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/blockencodings.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
9999

100100
std::vector<bool> have_txn(txn_available.size());
101101
LOCK(pool->cs);
102-
for (CTxMemPool::txiter it = pool->mapTx.begin(); it != pool->mapTx.end(); it++) {
103-
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(cmpctblock.GetShortID(it->GetTx().GetHash()));
102+
const std::vector<std::pair<uint256, CTxMemPool::txiter> >& vTxHashes = pool->vTxHashes;
103+
for (size_t i = 0; i < vTxHashes.size(); i++) {
104+
uint64_t shortid = cmpctblock.GetShortID(vTxHashes[i].first);
105+
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid);
104106
if (idit != shorttxids.end()) {
105107
if (!have_txn[idit->second]) {
106-
txn_available[idit->second] = it->GetSharedTx();
108+
txn_available[idit->second] = vTxHashes[i].second->GetSharedTx();
107109
have_txn[idit->second] = true;
108110
mempool_count++;
109111
} else {

0 commit comments

Comments
 (0)