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

Method BatchWrite

src/test/coins_tests.cpp:60–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

WriteCoinsViewEntryFunction · 0.45

Calls 8

BeginMethod · 0.80
EndMethod · 0.80
NextAndMaybeEraseMethod · 0.80
randrangeMethod · 0.80
IsDirtyMethod · 0.45
IsSpentMethod · 0.45
eraseMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected