Bitcoin Core 30.99.0
P2P Digital Currency
coins.cpp
Go to the documentation of this file.
1// Copyright (c) 2012-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <coins.h>
6
8#include <random.h>
9#include <uint256.h>
10#include <util/log.h>
11#include <util/trace.h>
12
13TRACEPOINT_SEMAPHORE(utxocache, add);
14TRACEPOINT_SEMAPHORE(utxocache, spent);
15TRACEPOINT_SEMAPHORE(utxocache, uncache);
16
17std::optional<Coin> CCoinsView::GetCoin(const COutPoint& outpoint) const { return std::nullopt; }
19std::vector<uint256> CCoinsView::GetHeadBlocks() const { return std::vector<uint256>(); }
21{
22 for (auto it{cursor.Begin()}; it != cursor.End(); it = cursor.NextAndMaybeErase(*it)) { }
23}
24
25std::unique_ptr<CCoinsViewCursor> CCoinsView::Cursor() const { return nullptr; }
26
27bool CCoinsView::HaveCoin(const COutPoint &outpoint) const
28{
29 return GetCoin(outpoint).has_value();
30}
31
33std::optional<Coin> CCoinsViewBacked::GetCoin(const COutPoint& outpoint) const { return base->GetCoin(outpoint); }
34bool CCoinsViewBacked::HaveCoin(const COutPoint &outpoint) const { return base->HaveCoin(outpoint); }
36std::vector<uint256> CCoinsViewBacked::GetHeadBlocks() const { return base->GetHeadBlocks(); }
37void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; }
38void CCoinsViewBacked::BatchWrite(CoinsViewCacheCursor& cursor, const uint256& hashBlock) { base->BatchWrite(cursor, hashBlock); }
39std::unique_ptr<CCoinsViewCursor> CCoinsViewBacked::Cursor() const { return base->Cursor(); }
41
42CCoinsViewCache::CCoinsViewCache(CCoinsView* baseIn, bool deterministic) :
43 CCoinsViewBacked(baseIn), m_deterministic(deterministic),
44 cacheCoins(0, SaltedOutpointHasher(/*deterministic=*/deterministic), CCoinsMap::key_equal{}, &m_cache_coins_memory_resource)
45{
46 m_sentinel.second.SelfRef(m_sentinel);
47}
48
51}
52
53CCoinsMap::iterator CCoinsViewCache::FetchCoin(const COutPoint &outpoint) const {
54 const auto [ret, inserted] = cacheCoins.try_emplace(outpoint);
55 if (inserted) {
56 if (auto coin{base->GetCoin(outpoint)}) {
57 ret->second.coin = std::move(*coin);
58 cachedCoinsUsage += ret->second.coin.DynamicMemoryUsage();
59 Assert(!ret->second.coin.IsSpent());
60 } else {
61 cacheCoins.erase(ret);
62 return cacheCoins.end();
63 }
64 }
65 return ret;
66}
67
68std::optional<Coin> CCoinsViewCache::GetCoin(const COutPoint& outpoint) const
69{
70 if (auto it{FetchCoin(outpoint)}; it != cacheCoins.end() && !it->second.coin.IsSpent()) return it->second.coin;
71 return std::nullopt;
72}
73
74void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possible_overwrite) {
75 assert(!coin.IsSpent());
76 if (coin.out.scriptPubKey.IsUnspendable()) return;
77 CCoinsMap::iterator it;
78 bool inserted;
79 std::tie(it, inserted) = cacheCoins.emplace(std::piecewise_construct, std::forward_as_tuple(outpoint), std::tuple<>());
80 bool fresh = false;
81 if (!possible_overwrite) {
82 if (!it->second.coin.IsSpent()) {
83 throw std::logic_error("Attempted to overwrite an unspent coin (when possible_overwrite is false)");
84 }
85 // If the coin exists in this cache as a spent coin and is DIRTY, then
86 // its spentness hasn't been flushed to the parent cache. We're
87 // re-adding the coin to this cache now but we can't mark it as FRESH.
88 // If we mark it FRESH and then spend it before the cache is flushed
89 // we would remove it from this cache and would never flush spentness
90 // to the parent cache.
91 //
92 // Re-adding a spent coin can happen in the case of a re-org (the coin
93 // is 'spent' when the block adding it is disconnected and then
94 // re-added when it is also added in a newly connected block).
95 //
96 // If the coin doesn't exist in the current cache, or is spent but not
97 // DIRTY, then it can be marked FRESH.
98 fresh = !it->second.IsDirty();
99 }
100 if (!inserted) {
101 cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
102 }
103 it->second.coin = std::move(coin);
105 if (fresh) CCoinsCacheEntry::SetFresh(*it, m_sentinel);
106 cachedCoinsUsage += it->second.coin.DynamicMemoryUsage();
107 TRACEPOINT(utxocache, add,
108 outpoint.hash.data(),
109 (uint32_t)outpoint.n,
110 (uint32_t)it->second.coin.nHeight,
111 (int64_t)it->second.coin.out.nValue,
112 (bool)it->second.coin.IsCoinBase());
113}
114
116 const auto mem_usage{coin.DynamicMemoryUsage()};
117 auto [it, inserted] = cacheCoins.try_emplace(std::move(outpoint), std::move(coin));
118 if (inserted) {
120 cachedCoinsUsage += mem_usage;
121 }
122}
123
124void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool check_for_overwrite) {
125 bool fCoinbase = tx.IsCoinBase();
126 const Txid& txid = tx.GetHash();
127 for (size_t i = 0; i < tx.vout.size(); ++i) {
128 bool overwrite = check_for_overwrite ? cache.HaveCoin(COutPoint(txid, i)) : fCoinbase;
129 // Coinbase transactions can always be overwritten, in order to correctly
130 // deal with the pre-BIP30 occurrences of duplicate coinbase transactions.
131 cache.AddCoin(COutPoint(txid, i), Coin(tx.vout[i], nHeight, fCoinbase), overwrite);
132 }
133}
134
135bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
136 CCoinsMap::iterator it = FetchCoin(outpoint);
137 if (it == cacheCoins.end()) return false;
138 cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
139 TRACEPOINT(utxocache, spent,
140 outpoint.hash.data(),
141 (uint32_t)outpoint.n,
142 (uint32_t)it->second.coin.nHeight,
143 (int64_t)it->second.coin.out.nValue,
144 (bool)it->second.coin.IsCoinBase());
145 if (moveout) {
146 *moveout = std::move(it->second.coin);
147 }
148 if (it->second.IsFresh()) {
149 cacheCoins.erase(it);
150 } else {
152 it->second.coin.Clear();
153 }
154 return true;
155}
156
157static const Coin coinEmpty;
158
159const Coin& CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
160 CCoinsMap::const_iterator it = FetchCoin(outpoint);
161 if (it == cacheCoins.end()) {
162 return coinEmpty;
163 } else {
164 return it->second.coin;
165 }
166}
167
168bool CCoinsViewCache::HaveCoin(const COutPoint &outpoint) const {
169 CCoinsMap::const_iterator it = FetchCoin(outpoint);
170 return (it != cacheCoins.end() && !it->second.coin.IsSpent());
171}
172
173bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
174 CCoinsMap::const_iterator it = cacheCoins.find(outpoint);
175 return (it != cacheCoins.end() && !it->second.coin.IsSpent());
176}
177
179 if (hashBlock.IsNull())
181 return hashBlock;
182}
183
184void CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
185 hashBlock = hashBlockIn;
186}
187
189{
190 for (auto it{cursor.Begin()}; it != cursor.End(); it = cursor.NextAndMaybeErase(*it)) {
191 if (!it->second.IsDirty()) { // TODO a cursor can only contain dirty entries
192 continue;
193 }
194 auto [itUs, inserted]{cacheCoins.try_emplace(it->first)};
195 if (inserted) {
196 if (it->second.IsFresh() && it->second.coin.IsSpent()) {
197 cacheCoins.erase(itUs); // TODO fresh coins should have been removed at spend
198 } else {
199 // The parent cache does not have an entry, while the child cache does.
200 // Move the data up and mark it as dirty.
201 CCoinsCacheEntry& entry{itUs->second};
202 assert(entry.coin.DynamicMemoryUsage() == 0);
203 if (cursor.WillErase(*it)) {
204 // Since this entry will be erased,
205 // we can move the coin into us instead of copying it
206 entry.coin = std::move(it->second.coin);
207 } else {
208 entry.coin = it->second.coin;
209 }
210 cachedCoinsUsage += entry.coin.DynamicMemoryUsage();
212 // We can mark it FRESH in the parent if it was FRESH in the child
213 // Otherwise it might have just been flushed from the parent's cache
214 // and already exist in the grandparent
215 if (it->second.IsFresh()) CCoinsCacheEntry::SetFresh(*itUs, m_sentinel);
216 }
217 } else {
218 // Found the entry in the parent cache
219 if (it->second.IsFresh() && !itUs->second.coin.IsSpent()) {
220 // The coin was marked FRESH in the child cache, but the coin
221 // exists in the parent cache. If this ever happens, it means
222 // the FRESH flag was misapplied and there is a logic error in
223 // the calling code.
224 throw std::logic_error("FRESH flag misapplied to coin that exists in parent cache");
225 }
226
227 if (itUs->second.IsFresh() && it->second.coin.IsSpent()) {
228 // The grandparent cache does not have an entry, and the coin
229 // has been spent. We can just delete it from the parent cache.
230 cachedCoinsUsage -= itUs->second.coin.DynamicMemoryUsage();
231 cacheCoins.erase(itUs);
232 } else {
233 // A normal modification.
234 cachedCoinsUsage -= itUs->second.coin.DynamicMemoryUsage();
235 if (cursor.WillErase(*it)) {
236 // Since this entry will be erased,
237 // we can move the coin into us instead of copying it
238 itUs->second.coin = std::move(it->second.coin);
239 } else {
240 itUs->second.coin = it->second.coin;
241 }
242 cachedCoinsUsage += itUs->second.coin.DynamicMemoryUsage();
244 // NOTE: It isn't safe to mark the coin as FRESH in the parent
245 // cache. If it already existed and was spent in the parent
246 // cache then marking it FRESH would prevent that spentness
247 // from being flushed to the grandparent.
248 }
249 }
250 }
251 SetBestBlock(hashBlockIn);
252}
253
254void CCoinsViewCache::Flush(bool reallocate_cache)
255{
256 auto cursor{CoinsViewCacheCursor(m_sentinel, cacheCoins, /*will_erase=*/true)};
257 base->BatchWrite(cursor, hashBlock);
258 cacheCoins.clear();
259 if (reallocate_cache) {
261 }
263}
264
266{
267 auto cursor{CoinsViewCacheCursor(m_sentinel, cacheCoins, /*will_erase=*/false)};
268 base->BatchWrite(cursor, hashBlock);
269 if (m_sentinel.second.Next() != &m_sentinel) {
270 /* BatchWrite must clear flags of all entries */
271 throw std::logic_error("Not all unspent flagged entries were cleared");
272 }
273}
274
276{
277 cacheCoins.clear();
280}
281
283{
284 CCoinsMap::iterator it = cacheCoins.find(hash);
285 if (it != cacheCoins.end() && !it->second.IsDirty()) {
286 cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
287 TRACEPOINT(utxocache, uncache,
288 hash.hash.data(),
289 (uint32_t)hash.n,
290 (uint32_t)it->second.coin.nHeight,
291 (int64_t)it->second.coin.out.nValue,
292 (bool)it->second.coin.IsCoinBase());
293 cacheCoins.erase(it);
294 }
295}
296
297unsigned int CCoinsViewCache::GetCacheSize() const {
298 return cacheCoins.size();
299}
300
302{
303 if (!tx.IsCoinBase()) {
304 for (unsigned int i = 0; i < tx.vin.size(); i++) {
305 if (!HaveCoin(tx.vin[i].prevout)) {
306 return false;
307 }
308 }
309 }
310 return true;
311}
312
314{
315 // Cache should be empty when we're calling this.
316 assert(cacheCoins.size() == 0);
317 cacheCoins.~CCoinsMap();
318 m_cache_coins_memory_resource.~CCoinsMapMemoryResource();
320 ::new (&cacheCoins) CCoinsMap{0, SaltedOutpointHasher{/*deterministic=*/m_deterministic}, CCoinsMap::key_equal{}, &m_cache_coins_memory_resource};
321}
322
324{
325 size_t recomputed_usage = 0;
326 size_t count_dirty = 0;
327 for (const auto& [_, entry] : cacheCoins) {
328 if (entry.coin.IsSpent()) {
329 assert(entry.IsDirty() && !entry.IsFresh()); // A spent coin must be dirty and cannot be fresh
330 } else {
331 assert(entry.IsDirty() || !entry.IsFresh()); // An unspent coin must not be fresh if not dirty
332 }
333
334 // Recompute cachedCoinsUsage.
335 recomputed_usage += entry.coin.DynamicMemoryUsage();
336
337 // Count the number of entries we expect in the linked list.
338 if (entry.IsDirty()) ++count_dirty;
339 }
340 // Iterate over the linked list of flagged entries.
341 size_t count_linked = 0;
342 for (auto it = m_sentinel.second.Next(); it != &m_sentinel; it = it->second.Next()) {
343 // Verify linked list integrity.
344 assert(it->second.Next()->second.Prev() == it);
345 assert(it->second.Prev()->second.Next() == it);
346 // Verify they are actually flagged.
347 assert(it->second.IsDirty());
348 // Count the number of entries actually in the list.
349 ++count_linked;
350 }
351 assert(count_linked == count_dirty);
352 assert(recomputed_usage == cachedCoinsUsage);
353}
354
357
358const Coin& AccessByTxid(const CCoinsViewCache& view, const Txid& txid)
359{
360 COutPoint iter(txid, 0);
361 while (iter.n < MAX_OUTPUTS_PER_BLOCK) {
362 const Coin& alternate = view.AccessCoin(iter);
363 if (!alternate.IsSpent()) return alternate;
364 ++iter.n;
365 }
366 return coinEmpty;
367}
368
369template <typename ReturnType, typename Func>
370static ReturnType ExecuteBackedWrapper(Func func, const std::vector<std::function<void()>>& err_callbacks)
371{
372 try {
373 return func();
374 } catch(const std::runtime_error& e) {
375 for (const auto& f : err_callbacks) {
376 f();
377 }
378 LogError("Error reading from database: %s\n", e.what());
379 // Starting the shutdown sequence and returning false to the caller would be
380 // interpreted as 'entry not found' (as opposed to unable to read data), and
381 // could lead to invalid interpretation. Just exit immediately, as we can't
382 // continue anyway, and all writes should be atomic.
383 std::abort();
384 }
385}
386
387std::optional<Coin> CCoinsViewErrorCatcher::GetCoin(const COutPoint& outpoint) const
388{
389 return ExecuteBackedWrapper<std::optional<Coin>>([&]() { return CCoinsViewBacked::GetCoin(outpoint); }, m_err_callbacks);
390}
391
393{
394 return ExecuteBackedWrapper<bool>([&]() { return CCoinsViewBacked::HaveCoin(outpoint); }, m_err_callbacks);
395}
int ret
#define Assert(val)
Identity function.
Definition: check.h:113
CCoinsView backed by another CCoinsView.
Definition: coins.h:336
void BatchWrite(CoinsViewCacheCursor &cursor, const uint256 &hashBlock) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:38
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:34
size_t EstimateSize() const override
Estimate database size (0 if not implemented)
Definition: coins.cpp:40
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:35
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:33
void SetBackend(CCoinsView &viewIn)
Definition: coins.cpp:37
std::unique_ptr< CCoinsViewCursor > Cursor() const override
Get a cursor to iterate over the whole state.
Definition: coins.cpp:39
CCoinsView * base
Definition: coins.h:338
std::vector< uint256 > GetHeadBlocks() const override
Retrieve the range of blocks that may have been only partially written.
Definition: coins.cpp:36
CCoinsViewBacked(CCoinsView *viewIn)
Definition: coins.cpp:32
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:355
void Sync()
Push the modifications applied to this cache to its base while retaining the contents of this cache (...
Definition: coins.cpp:265
CCoinsViewCache(CCoinsView *baseIn, bool deterministic=false)
Definition: coins.cpp:42
const bool m_deterministic
Definition: coins.h:357
uint256 hashBlock
Make mutable so that we can "fill the cache" even from Get-methods declared as "const".
Definition: coins.h:364
CCoinsMapMemoryResource m_cache_coins_memory_resource
Definition: coins.h:365
bool SpendCoin(const COutPoint &outpoint, Coin *moveto=nullptr)
Spend a coin.
Definition: coins.cpp:135
void Uncache(const COutPoint &outpoint)
Removes the UTXO with the given outpoint from the cache, if it is not modified.
Definition: coins.cpp:282
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view.
Definition: coins.cpp:301
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:74
void Flush(bool reallocate_cache=true)
Push the modifications applied to this cache to its base and wipe local state.
Definition: coins.cpp:254
void Reset() noexcept
Discard all modifications made to this cache without flushing to the base view.
Definition: coins.cpp:275
unsigned int GetCacheSize() const
Calculate the size of the cache (in number of transaction outputs)
Definition: coins.cpp:297
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:178
size_t cachedCoinsUsage
Definition: coins.h:371
void SetBestBlock(const uint256 &hashBlock)
Definition: coins.cpp:184
CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const
Definition: coins.cpp:53
bool HaveCoinInCache(const COutPoint &outpoint) const
Check if we have the given utxo already loaded in this cache.
Definition: coins.cpp:173
CoinsCachePair m_sentinel
Definition: coins.h:367
size_t DynamicMemoryUsage() const
Calculate the size of the cache (in bytes)
Definition: coins.cpp:49
void BatchWrite(CoinsViewCacheCursor &cursor, const uint256 &hashBlock) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:188
void EmplaceCoinInternalDANGER(COutPoint &&outpoint, Coin &&coin)
Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty.
Definition: coins.cpp:115
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:168
void SanityCheck() const
Run an internal sanity check on the cache data structure. *‍/.
Definition: coins.cpp:323
CCoinsMap cacheCoins
Definition: coins.h:368
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:68
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Definition: coins.cpp:159
void ReallocateCache()
Force a reallocation of the cache map.
Definition: coins.cpp:313
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:387
std::vector< std::function< void()> > m_err_callbacks
A list of callbacks to execute upon leveldb read error.
Definition: coins.h:542
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:392
Abstract view on the open txout dataset.
Definition: coins.h:302
virtual std::optional< Coin > GetCoin(const COutPoint &outpoint) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:17
virtual void BatchWrite(CoinsViewCacheCursor &cursor, const uint256 &hashBlock)
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:20
virtual std::vector< uint256 > GetHeadBlocks() const
Retrieve the range of blocks that may have been only partially written.
Definition: coins.cpp:19
virtual bool HaveCoin(const COutPoint &outpoint) const
Just check whether a given outpoint is unspent.
Definition: coins.cpp:27
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
Definition: coins.h:330
virtual std::unique_ptr< CCoinsViewCursor > Cursor() const
Get a cursor to iterate over the whole state.
Definition: coins.cpp:25
virtual uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:18
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
uint32_t n
Definition: transaction.h:32
Txid hash
Definition: transaction.h:31
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:281
const std::vector< CTxOut > vout
Definition: transaction.h:292
bool IsCoinBase() const
Definition: transaction.h:341
const Txid & GetHash() const LIFETIMEBOUND
Definition: transaction.h:328
const std::vector< CTxIn > vin
Definition: transaction.h:291
An output of a transaction.
Definition: transaction.h:140
A UTXO entry.
Definition: coins.h:34
bool IsSpent() const
Either this coin never existed (see e.g.
Definition: coins.h:82
constexpr bool IsNull() const
Definition: uint256.h:48
constexpr const std::byte * data() const
256-bit opaque blob.
Definition: uint256.h:195
static const uint256 ZERO
Definition: uint256.h:203
static const Coin coinEmpty
Definition: coins.cpp:157
TRACEPOINT_SEMAPHORE(utxocache, add)
static const uint64_t MAX_OUTPUTS_PER_BLOCK
Definition: coins.cpp:356
static const uint64_t MIN_TRANSACTION_OUTPUT_WEIGHT
Definition: coins.cpp:355
static ReturnType ExecuteBackedWrapper(Func func, const std::vector< std::function< void()> > &err_callbacks)
Definition: coins.cpp:370
const Coin & AccessByTxid(const CCoinsViewCache &view, const Txid &txid)
Utility function to find any unspent output with a given txid.
Definition: coins.cpp:358
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check_for_overwrite)
Utility function to add all of a transaction's outputs to a cache.
Definition: coins.cpp:124
std::unordered_map< COutPoint, CCoinsCacheEntry, SaltedOutpointHasher, std::equal_to< COutPoint >, PoolAllocator< CoinsCachePair, sizeof(CoinsCachePair)+sizeof(void *) *4 > > CCoinsMap
PoolAllocator's MAX_BLOCK_SIZE_BYTES parameter here uses sizeof the data, and adds the size of 4 poin...
Definition: coins.h:223
CCoinsMap::allocator_type::ResourceType CCoinsMapMemoryResource
Definition: coins.h:225
static const unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
Definition: consensus.h:15
static const int WITNESS_SCALE_FACTOR
Definition: consensus.h:21
#define LogError(...)
Definition: log.h:97
unsigned int nHeight
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
Definition: memusage.h:31
bool Func(const std::string &str, std::span< const char > &sp)
Parse a function call.
Definition: parsing.cpp:24
uint64_t GetSerializeSize(const T &t)
Definition: serialize.h:1095
A Coin in one level of the coins database caching hierarchy.
Definition: coins.h:109
static void SetFresh(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
Definition: coins.h:172
static void SetDirty(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
Definition: coins.h:171
Cursor for iterating over the linked list of flagged entries in CCoinsViewCache.
Definition: coins.h:260
CoinsCachePair * NextAndMaybeErase(CoinsCachePair &current) noexcept
Return the next entry after current, possibly erasing current.
Definition: coins.h:277
bool WillErase(CoinsCachePair &current) const noexcept
Definition: coins.h:293
CoinsCachePair * Begin() const noexcept
Definition: coins.h:273
CoinsCachePair * End() const noexcept
Definition: coins.h:274
#define TRACEPOINT(context,...)
Definition: trace.h:56
consteval auto _(util::TranslatedLiteral str)
Definition: translation.h:79
assert(!tx.IsCoinBase())