mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
coins: drop cursor from base view
`CCoinsView` does not need to expose cursor iteration now that the few cursor users take `CCoinsViewDB` directly. Keep `Cursor()` on `CCoinsViewDB`, where iteration is supported, and remove the empty, forwarding, and throwing base-view overrides. This also removes the coins_view fuzz target probe that only asserted the unsupported `CCoinsViewCache::Cursor()` throw path. Co-authored-by: sedited <seb.kung@gmail.com>
This commit is contained in:
@@ -335,9 +335,6 @@ public:
|
||||
//! The passed cursor is used to iterate through the coins.
|
||||
virtual void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) = 0;
|
||||
|
||||
//! Get a cursor to iterate over the whole state. Implementations may return nullptr.
|
||||
virtual std::unique_ptr<CCoinsViewCursor> Cursor() const = 0;
|
||||
|
||||
//! Estimate database size
|
||||
virtual size_t EstimateSize() const = 0;
|
||||
};
|
||||
@@ -363,7 +360,6 @@ public:
|
||||
{
|
||||
for (auto it{cursor.Begin()}; it != cursor.End(); it = cursor.NextAndMaybeErase(*it)) { }
|
||||
}
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const override { return {}; }
|
||||
size_t EstimateSize() const override { return 0; }
|
||||
};
|
||||
|
||||
@@ -384,7 +380,6 @@ public:
|
||||
uint256 GetBestBlock() const override { return base->GetBestBlock(); }
|
||||
std::vector<uint256> GetHeadBlocks() const override { return base->GetHeadBlocks(); }
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override { base->BatchWrite(cursor, block_hash); }
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const override { return base->Cursor(); }
|
||||
size_t EstimateSize() const override { return base->EstimateSize(); }
|
||||
};
|
||||
|
||||
@@ -435,9 +430,6 @@ public:
|
||||
uint256 GetBestBlock() const override;
|
||||
void SetBestBlock(const uint256& block_hash);
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override;
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const override {
|
||||
throw std::logic_error("CCoinsViewCache cursor iteration not supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have the given utxo already loaded in this cache.
|
||||
|
||||
@@ -227,13 +227,6 @@ void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsViewCache& co
|
||||
}
|
||||
|
||||
{
|
||||
bool expected_code_path = false;
|
||||
try {
|
||||
(void)coins_view_cache.Cursor();
|
||||
} catch (const std::logic_error&) {
|
||||
expected_code_path = true;
|
||||
}
|
||||
assert(expected_code_path);
|
||||
(void)coins_view_cache.DynamicMemoryUsage();
|
||||
(void)coins_view_cache.EstimateSize();
|
||||
(void)coins_view_cache.GetBestBlock();
|
||||
|
||||
@@ -52,7 +52,8 @@ public:
|
||||
uint256 GetBestBlock() const override;
|
||||
std::vector<uint256> GetHeadBlocks() const override;
|
||||
void BatchWrite(CoinsViewCacheCursor& cursor, const uint256& block_hash) override;
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const override;
|
||||
//! Get a cursor to iterate over the whole state.
|
||||
std::unique_ptr<CCoinsViewCursor> Cursor() const;
|
||||
|
||||
//! Whether an unsupported database format is used.
|
||||
bool NeedsUpgrade();
|
||||
|
||||
Reference in New Issue
Block a user