Bitcoin ABC 0.33.6
P2P Digital Currency
coins.cpp
Go to the documentation of this file.
1// Copyright (c) 2012-2016 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 <uint256.h>
11#include <util/trace.h>
12
13std::optional<Coin> CCoinsView::GetCoin(const COutPoint &outpoint) const {
14 return std::nullopt;
15}
17 return BlockHash();
18}
19std::vector<BlockHash> CCoinsView::GetHeadBlocks() const {
20 return std::vector<BlockHash>();
21}
23 const BlockHash &hashBlock) {
24 for (auto it{cursor.Begin()}; it != cursor.End();
25 it = cursor.NextAndMaybeErase(*it)) {
26 }
27}
29 return nullptr;
30}
31bool CCoinsView::HaveCoin(const COutPoint &outpoint) const {
32 return GetCoin(outpoint).has_value();
33}
34
36std::optional<Coin> CCoinsViewBacked::GetCoin(const COutPoint &outpoint) const {
37 return base->GetCoin(outpoint);
38}
39bool CCoinsViewBacked::HaveCoin(const COutPoint &outpoint) const {
40 return base->HaveCoin(outpoint);
41}
43 return base->GetBestBlock();
44}
45std::vector<BlockHash> CCoinsViewBacked::GetHeadBlocks() const {
46 return base->GetHeadBlocks();
47}
49 base = &viewIn;
50}
52 const BlockHash &hashBlock) {
53 base->BatchWrite(cursor, hashBlock);
54}
56 return base->Cursor();
57}
59 return base->EstimateSize();
60}
61
62CCoinsViewCache::CCoinsViewCache(CCoinsView *baseIn, bool deterministic)
63 : CCoinsViewBacked(baseIn), m_deterministic(deterministic),
64 cacheCoins(0, SaltedOutpointHasher(/*deterministic=*/deterministic),
65 CCoinsMap::key_equal{}, &m_cache_coins_memory_resource),
66 cachedCoinsUsage(0) {
67 m_sentinel.second.SelfRef(m_sentinel);
68}
69
72}
73
74CCoinsMap::iterator
75CCoinsViewCache::FetchCoin(const COutPoint &outpoint) const {
76 const auto [ret, inserted] = cacheCoins.try_emplace(outpoint);
77 if (inserted) {
78 if (auto coin{base->GetCoin(outpoint)}) {
79 ret->second.coin = std::move(*coin);
80 cachedCoinsUsage += ret->second.coin.DynamicMemoryUsage();
81 Assert(!ret->second.coin.IsSpent());
82 } else {
83 cacheCoins.erase(ret);
84 return cacheCoins.end();
85 }
86 }
87 return ret;
88}
89
90std::optional<Coin> CCoinsViewCache::GetCoin(const COutPoint &outpoint) const {
91 if (auto it{FetchCoin(outpoint)};
92 it != cacheCoins.end() && !it->second.coin.IsSpent()) {
93 return it->second.coin;
94 }
95 return std::nullopt;
96}
97
98void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin coin,
99 bool possible_overwrite) {
100 assert(!coin.IsSpent());
101 if (coin.GetTxOut().scriptPubKey.IsUnspendable()) {
102 return;
103 }
104 CCoinsMap::iterator it;
105 bool inserted;
106 std::tie(it, inserted) =
107 cacheCoins.emplace(std::piecewise_construct,
108 std::forward_as_tuple(outpoint), std::tuple<>());
109 bool fresh = false;
110 if (!possible_overwrite) {
111 if (!it->second.coin.IsSpent()) {
112 throw std::logic_error("Attempted to overwrite an unspent coin "
113 "(when possible_overwrite is false)");
114 }
115 // If the coin exists in this cache as a spent coin and is DIRTY, then
116 // its spentness hasn't been flushed to the parent cache. We're
117 // re-adding the coin to this cache now but we can't mark it as FRESH.
118 // If we mark it FRESH and then spend it before the cache is flushed
119 // we would remove it from this cache and would never flush spentness
120 // to the parent cache.
121 //
122 // Re-adding a spent coin can happen in the case of a re-org (the coin
123 // is 'spent' when the block adding it is disconnected and then
124 // re-added when it is also added in a newly connected block).
125 //
126 // If the coin doesn't exist in the current cache, or is spent but not
127 // DIRTY, then it can be marked FRESH.
128 fresh = !it->second.IsDirty();
129 }
130 if (!inserted) {
131 Assume(TrySub(m_dirty_count, it->second.IsDirty()));
132 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
133 }
134 it->second.coin = std::move(coin);
137 if (fresh) {
139 }
140 cachedCoinsUsage += it->second.coin.DynamicMemoryUsage();
141 TRACE5(utxocache, add, outpoint.GetTxId().data(), outpoint.GetN(),
142 coin.GetHeight(), coin.GetTxOut().nValue.ToString().c_str(),
143 coin.IsCoinBase());
144}
145
147 Coin &&coin) {
148 const auto mem_usage{coin.DynamicMemoryUsage()};
149 auto [it, inserted] =
150 cacheCoins.try_emplace(std::move(outpoint), std::move(coin));
151 if (inserted) {
154 cachedCoinsUsage += mem_usage;
155 }
156}
157
158void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight,
159 bool check_for_overwrite) {
160 bool fCoinbase = tx.IsCoinBase();
161 const TxId txid = tx.GetId();
162 for (size_t i = 0; i < tx.vout.size(); ++i) {
163 const COutPoint outpoint(txid, i);
164 bool overwrite =
165 check_for_overwrite ? cache.HaveCoin(outpoint) : fCoinbase;
166 // Coinbase transactions can always be overwritten,
167 // in order to correctly deal with the pre-BIP30 occurrences of
168 // duplicate coinbase transactions.
169 cache.AddCoin(outpoint, Coin(tx.vout[i], nHeight, fCoinbase),
170 overwrite);
171 }
172}
173
174bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin *moveout) {
175 CCoinsMap::iterator it = FetchCoin(outpoint);
176 if (it == cacheCoins.end()) {
177 return false;
178 }
179 Assume(TrySub(m_dirty_count, it->second.IsDirty()));
180 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
181 TRACE5(utxocache, spent, outpoint.GetTxId().data(), outpoint.GetN(),
182 it->second.coin.GetHeight(),
183 it->second.coin.GetTxOut().nValue.ToString().c_str(),
184 it->second.coin.IsCoinBase());
185 if (moveout) {
186 *moveout = std::move(it->second.coin);
187 }
188 if (it->second.IsFresh()) {
189 cacheCoins.erase(it);
190 } else {
193 it->second.coin.Clear();
194 }
195 return true;
196}
197
198static const Coin coinEmpty;
199
200const Coin &CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
201 CCoinsMap::const_iterator it = FetchCoin(outpoint);
202 if (it == cacheCoins.end()) {
203 return coinEmpty;
204 }
205 return it->second.coin;
206}
207
208bool CCoinsViewCache::HaveCoin(const COutPoint &outpoint) const {
209 CCoinsMap::const_iterator it = FetchCoin(outpoint);
210 return it != cacheCoins.end() && !it->second.coin.IsSpent();
211}
212
213bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
214 CCoinsMap::const_iterator it = cacheCoins.find(outpoint);
215 return (it != cacheCoins.end() && !it->second.coin.IsSpent());
216}
217
219 if (hashBlock.IsNull()) {
221 }
222 return hashBlock;
223}
224
225void CCoinsViewCache::SetBestBlock(const BlockHash &hashBlockIn) {
226 hashBlock = hashBlockIn;
227}
228
230 const BlockHash &hashBlockIn) {
231 for (auto it{cursor.Begin()}; it != cursor.End();
232 it = cursor.NextAndMaybeErase(*it)) {
233 if (!it->second.IsDirty()) {
234 // TODO a cursor can only contain dirty entries
235 continue;
236 }
237 auto [itUs, inserted]{cacheCoins.try_emplace(it->first)};
238 if (inserted) {
239 if (it->second.IsFresh() && it->second.coin.IsSpent()) {
240 // TODO fresh coins should have been removed at spend
241 cacheCoins.erase(itUs);
242 } else {
243 // The parent cache does not have an entry, while the child
244 // cache does. Move the data up and mark it as dirty.
245 CCoinsCacheEntry &entry{itUs->second};
246 assert(entry.coin.DynamicMemoryUsage() == 0);
247 if (cursor.WillErase(*it)) {
248 // Since this entry will be erased,
249 // we can move the coin into us instead of copying it
250 entry.coin = std::move(it->second.coin);
251 } else {
252 entry.coin = it->second.coin;
253 }
256 cachedCoinsUsage += entry.coin.DynamicMemoryUsage();
257 // We can mark it FRESH in the parent if it was FRESH in the
258 // child. Otherwise it might have just been flushed from the
259 // parent's cache and already exist in the grandparent
260 if (it->second.IsFresh()) {
262 }
263 }
264 } else {
265 // Found the entry in the parent cache
266 if (it->second.IsFresh() && !itUs->second.coin.IsSpent()) {
267 // The coin was marked FRESH in the child cache, but the coin
268 // exists in the parent cache. If this ever happens, it means
269 // the FRESH flag was misapplied and there is a logic error in
270 // the calling code.
271 throw std::logic_error("FRESH flag misapplied to coin that "
272 "exists in parent cache");
273 }
274
275 if (itUs->second.IsFresh() && it->second.coin.IsSpent()) {
276 // The grandparent cache does not have an entry, and the coin
277 // has been spent. We can just delete it from the parent cache.
278 Assume(TrySub(m_dirty_count, itUs->second.IsDirty()));
280 itUs->second.coin.DynamicMemoryUsage()));
281 cacheCoins.erase(itUs);
282 } else {
283 // A normal modification.
285 itUs->second.coin.DynamicMemoryUsage()));
286 if (cursor.WillErase(*it)) {
287 // Since this entry will be erased,
288 // we can move the coin into us instead of copying it
289 itUs->second.coin = std::move(it->second.coin);
290 } else {
291 itUs->second.coin = it->second.coin;
292 }
293 cachedCoinsUsage += itUs->second.coin.DynamicMemoryUsage();
294 if (!itUs->second.IsDirty()) {
297 }
298 // NOTE: It isn't safe to mark the coin as FRESH in the parent
299 // cache. If it already existed and was spent in the parent
300 // cache then marking it FRESH would prevent that spentness
301 // from being flushed to the grandparent.
302 }
303 }
304 }
305 SetBestBlock(hashBlockIn);
306}
307
308void CCoinsViewCache::Flush(bool reallocate_cache) {
310 /*will_erase=*/true)};
311 base->BatchWrite(cursor, hashBlock);
312 Assume(m_dirty_count == 0);
313 cacheCoins.clear();
314 if (reallocate_cache) {
316 }
318}
319
322 /*will_erase=*/false)};
323 base->BatchWrite(cursor, hashBlock);
324 Assume(m_dirty_count == 0);
325 if (m_sentinel.second.Next() != &m_sentinel) {
326 /* BatchWrite must clear flags of all entries */
327 throw std::logic_error("Not all unspent flagged entries were cleared");
328 }
329}
330
331void CCoinsViewCache::Reset() noexcept {
332 cacheCoins.clear();
334 m_dirty_count = 0;
336}
337
338void CCoinsViewCache::Uncache(const COutPoint &outpoint) {
339 CCoinsMap::iterator it = cacheCoins.find(outpoint);
340 if (it != cacheCoins.end() && !it->second.IsDirty()) {
341 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
342 TRACE5(utxocache, uncache, outpoint.GetTxId().data(), outpoint.GetN(),
343 it->second.coin.GetHeight(),
344 it->second.coin.GetTxOut().nValue.ToString().c_str(),
345 it->second.coin.IsCoinBase());
346 cacheCoins.erase(it);
347 }
348}
349
350unsigned int CCoinsViewCache::GetCacheSize() const {
351 return cacheCoins.size();
352}
353
354bool CCoinsViewCache::HaveInputs(const CTransaction &tx) const {
355 if (tx.IsCoinBase()) {
356 return true;
357 }
358
359 for (size_t i = 0; i < tx.vin.size(); i++) {
360 if (!HaveCoin(tx.vin[i].prevout)) {
361 return false;
362 }
363 }
364
365 return true;
366}
367
369 // Cache should be empty when we're calling this.
370 assert(cacheCoins.size() == 0);
371 cacheCoins.~CCoinsMap();
372 m_cache_coins_memory_resource.~CCoinsMapMemoryResource();
374 ::new (&cacheCoins)
375 CCoinsMap{0, SaltedOutpointHasher{/*deterministic=*/m_deterministic},
376 CCoinsMap::key_equal{}, &m_cache_coins_memory_resource};
377}
378
380 size_t recomputed_usage = 0;
381 size_t count_dirty = 0;
382 for (const auto &[_, entry] : cacheCoins) {
383 if (entry.coin.IsSpent()) {
384 // A spent coin must be dirty and cannot be fresh
385 assert(entry.IsDirty() && !entry.IsFresh());
386 } else {
387 // An unspent coin must not be fresh if not dirty
388 assert(entry.IsDirty() || !entry.IsFresh());
389 }
390
391 // Recompute cachedCoinsUsage.
392 recomputed_usage += entry.coin.DynamicMemoryUsage();
393
394 // Count the number of entries we expect in the linked list.
395 if (entry.IsDirty()) {
396 ++count_dirty;
397 }
398 }
399 // Iterate over the linked list of flagged entries.
400 size_t count_linked = 0;
401 for (auto it = m_sentinel.second.Next(); it != &m_sentinel;
402 it = it->second.Next()) {
403 // Verify linked list integrity.
404 assert(it->second.Next()->second.Prev() == it);
405 assert(it->second.Prev()->second.Next() == it);
406 // Verify they are actually flagged.
407 assert(it->second.IsDirty());
408 // Count the number of entries actually in the list.
409 ++count_linked;
410 }
411 assert(count_dirty == count_linked && count_dirty == m_dirty_count);
412 assert(recomputed_usage == cachedCoinsUsage);
413}
414
415// TODO: merge with similar definition in undo.h.
416static const size_t MAX_OUTPUTS_PER_TX =
418
419const Coin &AccessByTxid(const CCoinsViewCache &view, const TxId &txid) {
420 for (uint32_t n = 0; n < MAX_OUTPUTS_PER_TX; n++) {
421 const Coin &alternate = view.AccessCoin(COutPoint(txid, n));
422 if (!alternate.IsSpent()) {
423 return alternate;
424 }
425 }
426
427 return coinEmpty;
428}
429
430template <typename ReturnType, typename Func>
431static ReturnType
433 const std::vector<std::function<void()>> &err_callbacks) {
434 try {
435 return func();
436 } catch (const std::runtime_error &e) {
437 for (const auto &f : err_callbacks) {
438 f();
439 }
440 LogError("Error reading from database: %s\n", e.what());
441 // Starting the shutdown sequence and returning false to the caller
442 // would be interpreted as 'entry not found' (as opposed to unable to
443 // read data), and could lead to invalid interpretation. Just exit
444 // immediately, as we can't continue anyway, and all writes should be
445 // atomic.
446 std::abort();
447 }
448}
449
450std::optional<Coin>
451CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint) const {
452 return ExecuteBackedWrapper<std::optional<Coin>>(
453 [&]() { return CCoinsViewBacked::GetCoin(outpoint); }, m_err_callbacks);
454}
455
456bool CCoinsViewErrorCatcher::HaveCoin(const COutPoint &outpoint) const {
457 return ExecuteBackedWrapper<bool>(
458 [&]() { return CCoinsViewBacked::HaveCoin(outpoint); },
460}
#define Assert(val)
Identity function.
Definition: check.h:84
#define Assume(val)
Assume is the identity function.
Definition: check.h:97
CCoinsView backed by another CCoinsView.
Definition: coins.h:338
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:39
BlockHash GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:42
CCoinsViewCursor * Cursor() const override
Get a cursor to iterate over the whole state.
Definition: coins.cpp:55
size_t EstimateSize() const override
Estimate database size (0 if not implemented)
Definition: coins.cpp:58
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:36
void SetBackend(CCoinsView &viewIn)
Definition: coins.cpp:48
CCoinsView * base
Definition: coins.h:340
std::vector< BlockHash > GetHeadBlocks() const override
Retrieve the range of blocks that may have been only partially written.
Definition: coins.cpp:45
void BatchWrite(CoinsViewCacheCursor &cursor, const BlockHash &hashBlock) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:51
CCoinsViewBacked(CCoinsView *viewIn)
Definition: coins.cpp:35
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:358
void Sync()
Push the modifications applied to this cache to its base while retaining the contents of this cache (...
Definition: coins.cpp:320
CCoinsViewCache(CCoinsView *baseIn, bool deterministic=false)
Definition: coins.cpp:62
void AddCoin(const COutPoint &outpoint, Coin coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:98
const bool m_deterministic
Definition: coins.h:360
BlockHash GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:218
CCoinsMapMemoryResource m_cache_coins_memory_resource
Definition: coins.h:368
bool SpendCoin(const COutPoint &outpoint, Coin *moveto=nullptr)
Spend a coin.
Definition: coins.cpp:174
void Uncache(const COutPoint &outpoint)
Removes the UTXO with the given outpoint from the cache, if it is not modified.
Definition: coins.cpp:338
void BatchWrite(CoinsViewCacheCursor &cursor, const BlockHash &hashBlock) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:229
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:354
void SetBestBlock(const BlockHash &hashBlock)
Definition: coins.cpp:225
BlockHash hashBlock
Make mutable so that we can "fill the cache" even from Get-methods declared as "const".
Definition: coins.h:367
size_t m_dirty_count
Definition: coins.h:378
void Flush(bool reallocate_cache=true)
Push the modifications applied to this cache to its base and wipe local state.
Definition: coins.cpp:308
void Reset() noexcept
Discard all modifications made to this cache without flushing to the base view.
Definition: coins.cpp:331
unsigned int GetCacheSize() const
Size of the cache (in number of transaction outputs)
Definition: coins.cpp:350
size_t cachedCoinsUsage
Definition: coins.h:376
CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const
Definition: coins.cpp:75
bool HaveCoinInCache(const COutPoint &outpoint) const
Check if we have the given utxo already loaded in this cache.
Definition: coins.cpp:213
CoinsCachePair m_sentinel
The starting sentinel of the flagged entry circular doubly linked list.
Definition: coins.h:372
size_t DynamicMemoryUsage() const
Calculate the size of the cache (in bytes)
Definition: coins.cpp:70
void EmplaceCoinInternalDANGER(COutPoint &&outpoint, Coin &&coin)
Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty.
Definition: coins.cpp:146
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:208
void SanityCheck() const
Run an internal sanity check on the cache data structure.
Definition: coins.cpp:379
CCoinsMap cacheCoins
Definition: coins.h:373
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:90
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Definition: coins.cpp:200
void ReallocateCache()
Force a reallocation of the cache map.
Definition: coins.cpp:368
Cursor for iterating over CoinsView state.
Definition: coins.h:217
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:451
std::vector< std::function< void()> > m_err_callbacks
A list of callbacks to execute upon leveldb read error.
Definition: coins.h:567
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:456
Abstract view on the open txout dataset.
Definition: coins.h:304
virtual void BatchWrite(CoinsViewCacheCursor &cursor, const BlockHash &hashBlock)
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:22
virtual std::optional< Coin > GetCoin(const COutPoint &outpoint) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:13
virtual CCoinsViewCursor * Cursor() const
Get a cursor to iterate over the whole state.
Definition: coins.cpp:28
virtual std::vector< BlockHash > GetHeadBlocks() const
Retrieve the range of blocks that may have been only partially written.
Definition: coins.cpp:19
virtual BlockHash GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:16
virtual bool HaveCoin(const COutPoint &outpoint) const
Just check whether a given outpoint is unspent.
Definition: coins.cpp:31
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
Definition: coins.h:334
An output of a transaction.
Definition: transaction.h:128
CScript scriptPubKey
Definition: transaction.h:131
Amount nValue
Definition: transaction.h:130
A UTXO entry.
Definition: coins.h:31
uint32_t GetHeight() const
Definition: coins.h:48
bool IsCoinBase() const
Definition: coins.h:49
CTxOut & GetTxOut()
Definition: coins.h:52
bool IsSpent() const
Definition: coins.h:50
bool IsNull() const
Definition: uint256.h:32
static const uint256 ZERO
Definition: uint256.h:134
static const size_t MAX_OUTPUTS_PER_TX
Definition: coins.cpp:416
const Coin & AccessByTxid(const CCoinsViewCache &view, const TxId &txid)
Utility function to find any unspent output with a given txid.
Definition: coins.cpp:419
static const Coin coinEmpty
Definition: coins.cpp:198
static ReturnType ExecuteBackedWrapper(Func func, const std::vector< std::function< void()> > &err_callbacks)
Definition: coins.cpp:432
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:158
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:212
CCoinsMap::allocator_type::ResourceType CCoinsMapMemoryResource
Definition: coins.h:214
static const uint64_t MAX_TX_SIZE
The maximum allowed size for a transaction, in bytes.
Definition: consensus.h:14
#define LogError(...)
Definition: logging.h:419
unsigned int nHeight
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
Definition: memusage.h:28
bool Func(const std::string &str, Span< const char > &sp)
Parse a function call.
Definition: parsing.cpp:23
constexpr bool TrySub(T &i, const U j) noexcept
Definition: overflow.h:32
size_t GetSerializeSize(const T &t)
Definition: serialize.h:1262
std::string ToString() const
Definition: amount.cpp:22
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
A Coin in one level of the coins database caching hierarchy.
Definition: coins.h:96
static void SetFresh(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
Definition: coins.h:161
static void SetDirty(CoinsCachePair &pair, CoinsCachePair &sentinel) noexcept
Definition: coins.h:157
Cursor for iterating over the linked list of flagged entries in CCoinsViewCache.
Definition: coins.h:250
CoinsCachePair * NextAndMaybeErase(CoinsCachePair &current) noexcept
Return the next entry after current, possibly erasing current.
Definition: coins.h:273
bool WillErase(CoinsCachePair &current) const noexcept
Definition: coins.h:290
CoinsCachePair * Begin() const noexcept
Definition: coins.h:267
CoinsCachePair * End() const noexcept
Definition: coins.h:270
A TxId is the identifier of a transaction.
Definition: txid.h:14
#define TRACE5(context, event, a, b, c, d, e)
Definition: trace.h:44
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:68
assert(!tx.IsCoinBase())