mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 12:19:28 -05:00
core: speed up output index unique set calculation
A sort+uniq step was done for every tx in a 200 block chunk, causing a lot of repeated scanning as the size of the offset map got larger with every added tx. We now do the step only once at the end of the loop. Doing it this way potentially uses more memory, but testing shows that it's currently only about 2% more.
This commit is contained in:
parent
19d7f568ce
commit
5d4ef719b9
@ -3866,6 +3866,8 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
|
||||
offset_map[in_to_key.amount].push_back(offset);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort and remove duplicate absolute_offsets in offset_map
|
||||
for (auto &offsets : offset_map)
|
||||
@ -3874,8 +3876,6 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
|
||||
auto last = std::unique(offsets.second.begin(), offsets.second.end());
|
||||
offsets.second.erase(last, offsets.second.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [output] stores all transactions for each tx_out_index::hash found
|
||||
std::vector<std::unordered_map<crypto::hash, cryptonote::transaction>> transactions(amounts.size());
|
||||
|
Loading…
Reference in New Issue
Block a user