File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -45,15 +45,18 @@ class CCoinsViewTest : public CCoinsView
45
45
bool BatchWrite (CCoinsMap& mapCoins, const uint256& hashBlock)
46
46
{
47
47
for (CCoinsMap::iterator it = mapCoins.begin (); it != mapCoins.end (); ) {
48
- map_[it->first ] = it->second .coins ;
49
- if (it->second .coins .IsPruned () && insecure_rand () % 3 == 0 ) {
50
- // Randomly delete empty entries on write.
51
- map_.erase (it->first );
48
+ if (it->second .flags & CCoinsCacheEntry::DIRTY) {
49
+ // Same optimization used in CCoinsViewDB is to only write dirty entries.
50
+ map_[it->first ] = it->second .coins ;
51
+ if (it->second .coins .IsPruned () && insecure_rand () % 3 == 0 ) {
52
+ // Randomly delete empty entries on write.
53
+ map_.erase (it->first );
54
+ }
52
55
}
53
56
mapCoins.erase (it++);
54
57
}
55
- mapCoins. clear ();
56
- hashBestBlock_ = hashBlock;
58
+ if (!hashBlock. IsNull ())
59
+ hashBestBlock_ = hashBlock;
57
60
return true ;
58
61
}
59
62
You can’t perform that action at this time.
0 commit comments