mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 23:58:18 +00:00
Make CCoinsViewTest behave like CCoinsViewDB
This commit is contained in:
parent
14470f9aa6
commit
03c82826f9
@ -45,15 +45,18 @@ public:
|
|||||||
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock)
|
bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock)
|
||||||
{
|
{
|
||||||
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) {
|
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) {
|
||||||
map_[it->first] = it->second.coins;
|
if (it->second.flags & CCoinsCacheEntry::DIRTY) {
|
||||||
if (it->second.coins.IsPruned() && insecure_rand() % 3 == 0) {
|
// Same optimization used in CCoinsViewDB is to only write dirty entries.
|
||||||
// Randomly delete empty entries on write.
|
map_[it->first] = it->second.coins;
|
||||||
map_.erase(it->first);
|
if (it->second.coins.IsPruned() && insecure_rand() % 3 == 0) {
|
||||||
|
// Randomly delete empty entries on write.
|
||||||
|
map_.erase(it->first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mapCoins.erase(it++);
|
mapCoins.erase(it++);
|
||||||
}
|
}
|
||||||
mapCoins.clear();
|
if (!hashBlock.IsNull())
|
||||||
hashBestBlock_ = hashBlock;
|
hashBestBlock_ = hashBlock;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user