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