MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / BatchWrite

Method BatchWrite

src/test/coins_tests.cpp:55–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
74class CCoinsViewCacheTest : public CCoinsViewCache

Callers 1

WriteCoinsViewEntryFunction · 0.45

Calls 6

InsecureRandRangeFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
IsSpentMethod · 0.45
eraseMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected