mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-12 23:13:25 +02:00
Merge bitcoin/bitcoin#34124: validation: make CCoinsView a pure virtual interface
8783cc8056refactor: inline `CCoinsViewBacked` implementation (Lőrinc)86296f276dcoins: make `CCoinsView` methods pure virtual (Lőrinc)b637566c8dcoins: add explicit `CoinsViewEmpty` noop backend (Lőrinc)90c635c01cfuzz: keep backend assertions aligned to active backend (Lőrinc)a9f92e3497refactor: normalize CCoinsView whitespace and signatures (Lőrinc)38a99f3344scripted-diff: normalize `CCoinsView` naming (Lőrinc)06172ef0d5refactor: rename `hashBlock` to `m_block_hash` to avoid shadowing (Lőrinc) Pull request description: ### Problem `CCoinsView` is the coins view interface, but historically it also provided built-in no-op behavior: * It provided default no-op implementations (returning `std::nullopt`, `uint256()`, `false`, or `nullptr`) instead of being pure virtual. * Callers could instantiate a bare `CCoinsView` and get silent no-op behavior. * Mixing the interface definition with a built-in dummy implementation blurred the abstraction boundary. ### Context This is part of the ongoing coins caching cleanup in #34280. ### Fix This PR separates the interface from no-op behavior and makes `CCoinsView` pure virtual in incremental steps: * Add `CoinsViewEmpty` as an explicit no-op coins view for tests, benchmarks, and temporary backends. * Replace direct bare-`CCoinsView` test and dummy instantiations with `CoinsViewEmpty`. * Make all `CCoinsView` methods pure virtual (`PeekCoin`, `GetCoin`, `HaveCoin`, `GetBestBlock`, `GetHeadBlocks`, `BatchWrite`, `Cursor`, `EstimateSize`). * Remove the legacy default implementations from `coins.cpp`. * Update fuzz and dummy backends to use `CoinsViewEmpty` explicitly. ACKs for top commit: w0xlt: reACK8783cc8056ryanofsky: Code review ACK8783cc8056. Just updated comments and variable name since last review. The fuzz test code is much clearer now IMO andrewtoth-exo: ACK8783cc8056ajtowns: ACK8783cc8056Tree-SHA512: cfc831578aa309788c1b5dafbfecca3de388cc4215534c3f3df24f90d7770ed37b1fd7aa134df91d611d0a1ca75929accb98d5ed7df7b52851c259e04f08e4a3
This commit is contained in:
@@ -116,8 +116,7 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
|
||||
|
||||
// Estimate the size
|
||||
CMutableTransaction mtx(*psbtx.tx);
|
||||
CCoinsView view_dummy;
|
||||
CCoinsViewCache view(&view_dummy);
|
||||
CCoinsViewCache view{&CoinsViewEmpty::Get()};
|
||||
bool success = true;
|
||||
|
||||
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
|
||||
|
||||
Reference in New Issue
Block a user