| 58 | uint256 GetBestBlock() const override { return hashBestBlock_; } |
| 59 | |
| 60 | void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override |
| 61 | { |
| 62 | for (auto it{cursor.Begin()}; it != cursor.End(); it = cursor.NextAndMaybeErase(*it)){ |
| 63 | if (it->second.IsDirty()) { |
| 64 | // Same optimization used in CCoinsViewDB is to only write dirty entries. |
| 65 | map_[it->first] = it->second.coin; |
| 66 | if (it->second.coin.IsSpent() && m_rng.randrange(3) == 0) { |
| 67 | // Randomly delete empty entries on write. |
| 68 | map_.erase(it->first); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | if (!block_hash.IsNull()) |
| 73 | hashBestBlock_ = block_hash; |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | class CCoinsViewCacheTest : public CCoinsViewCache |
no test coverage detected