mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-28 14:55:22 +02:00
coins: add explicit CoinsViewEmpty noop backend
Introduce `CoinsViewEmpty` as an explicit no-op `CCoinsView` implementation, and define its singleton accessor out of line in `coins.cpp` to avoid `-Wunique-object-duplication` in shared-library builds.` Use it at call sites that intentionally want a no-op backend instead of constructing anonymous placeholder views. `CCoinsViewTest` and `CoinsViewBottom` now inherit defaults from `CoinsViewEmpty` (e.g. the unused `EstimateSize()`, which now returns 0). Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -139,7 +139,7 @@ struct CacheLevel
|
||||
*
|
||||
* The initial state consists of the empty UTXO set.
|
||||
*/
|
||||
class CoinsViewBottom final : public CCoinsView
|
||||
class CoinsViewBottom final : public CoinsViewEmpty
|
||||
{
|
||||
std::map<COutPoint, Coin> m_data;
|
||||
|
||||
@@ -153,11 +153,6 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
uint256 GetBestBlock() const final { return {}; }
|
||||
std::vector<uint256> GetHeadBlocks() const final { return {}; }
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const final { return {}; }
|
||||
size_t EstimateSize() const final { return m_data.size(); }
|
||||
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256&) final
|
||||
{
|
||||
for (auto it{cursor.Begin()}; it != cursor.End(); it = cursor.NextAndMaybeErase(*it)) {
|
||||
|
||||
Reference in New Issue
Block a user