Try using cache in GetListForBlock before reading from disk (#2253)
* Try using cache in GetListForBlock before reading from disk * Use std::list for vecDiff
This commit is contained in:
parent
2900760dac
commit
88e7888de9
@ -506,9 +506,16 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlock(const uint256& blo
|
||||
|
||||
uint256 blockHashTmp = blockHash;
|
||||
CDeterministicMNList snapshot;
|
||||
std::vector<CDeterministicMNListDiff> vecDiff;
|
||||
std::list<CDeterministicMNListDiff> listDiff;
|
||||
|
||||
while(true) {
|
||||
// try using cache before reading from disk
|
||||
it = mnListsCache.find(blockHashTmp);
|
||||
if (it != mnListsCache.end()) {
|
||||
snapshot = it->second;
|
||||
break;
|
||||
}
|
||||
|
||||
if (evoDb.Read(std::make_pair(DB_LIST_SNAPSHOT, blockHashTmp), snapshot)) {
|
||||
break;
|
||||
}
|
||||
@ -519,11 +526,11 @@ CDeterministicMNList CDeterministicMNManager::GetListForBlock(const uint256& blo
|
||||
break;
|
||||
}
|
||||
|
||||
vecDiff.emplace(vecDiff.begin(), diff);
|
||||
listDiff.emplace_front(diff);
|
||||
blockHashTmp = diff.prevBlockHash;
|
||||
}
|
||||
|
||||
for (const auto& diff : vecDiff) {
|
||||
for (const auto& diff : listDiff) {
|
||||
if (diff.HasChanges()) {
|
||||
snapshot = snapshot.ApplyDiff(diff);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user