mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-14 00:30:17 +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:
@@ -623,8 +623,7 @@ static RPCMethod combinerawtransaction()
|
||||
CMutableTransaction mergedTx(txVariants[0]);
|
||||
|
||||
// Fetch previous transactions (inputs):
|
||||
CCoinsView viewDummy;
|
||||
CCoinsViewCache view(&viewDummy);
|
||||
CCoinsViewCache view{&CoinsViewEmpty::Get()};
|
||||
{
|
||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
const CTxMemPool& mempool = EnsureMemPool(node);
|
||||
@@ -638,7 +637,7 @@ static RPCMethod combinerawtransaction()
|
||||
view.AccessCoin(txin.prevout); // Load entries from viewChain into view; can fail.
|
||||
}
|
||||
|
||||
view.SetBackend(viewDummy); // switch back to avoid locking mempool for too long
|
||||
view.SetBackend(CoinsViewEmpty::Get()); // switch back to avoid locking mempool for too long
|
||||
}
|
||||
|
||||
// Use CTransaction for the constant parts of the
|
||||
|
||||
Reference in New Issue
Block a user