| 53 | uint256 GetBestBlock() const override { return hashBestBlock_; } |
| 54 | |
| 55 | bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock) override |
| 56 | { |
| 57 | for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) { |
| 58 | if (it->second.flags & CCoinsCacheEntry::DIRTY) { |
| 59 | // Same optimization used in CCoinsViewDB is to only write dirty entries. |
| 60 | map_[it->first] = it->second.coin; |
| 61 | if (it->second.coin.IsSpent() && InsecureRandRange(3) == 0) { |
| 62 | // Randomly delete empty entries on write. |
| 63 | map_.erase(it->first); |
| 64 | } |
| 65 | } |
| 66 | mapCoins.erase(it++); |
| 67 | } |
| 68 | if (!hashBlock.IsNull()) |
| 69 | hashBestBlock_ = hashBlock; |
| 70 | return true; |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | class CCoinsViewCacheTest : public CCoinsViewCache |
no test coverage detected