MCPcopy Create free account
hub / github.com/ElementsProject/elements / BatchWrite

Method BatchWrite

src/test/coins_tests.cpp:57–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

WriteCoinsViewEntryFunction · 0.45
FUZZ_TARGET_INITFunction · 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