Bitcoin ABC 0.33.12
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 m_sentinel.second.SelfRef(m_sentinel);
67}
68
71}
72
73CCoinsMap::iterator
74CCoinsViewCache::FetchCoin(const COutPoint &outpoint) const {
75 const auto [ret, inserted] = cacheCoins.try_emplace(outpoint);
76 if (inserted) {
77 if (auto coin{base->GetCoin(outpoint)}) {
78 ret->second.coin = std::move(*coin);
79 cachedCoinsUsage += ret->second.coin.DynamicMemoryUsage();
80 Assert(!ret->second.coin.IsSpent());
81 } else {
82 cacheCoins.erase(ret);
83 return cacheCoins.end();
84 }
85 }
86 return ret;
87}
88
89std::optional<Coin> CCoinsViewCache::GetCoin(const COutPoint &outpoint) const {
90 if (auto it{FetchCoin(outpoint)};
91 it != cacheCoins.end() && !it->second.coin.IsSpent()) {
92 return it->second.coin;
93 }
94 return std::nullopt;
95}
96
97void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin coin,
98 bool possible_overwrite) {
99 assert(!coin.IsSpent());
100 if (coin.GetTxOut().scriptPubKey.IsUnspendable()) {
101 return;
102 }
103 CCoinsMap::iterator it;
104 bool inserted;
105 std::tie(it, inserted) =
106 cacheCoins.emplace(std::piecewise_construct,
107 std::forward_as_tuple(outpoint), std::tuple<>());
108 bool fresh = false;
109 if (!possible_overwrite) {
110 if (!it->second.coin.IsSpent()) {
111 throw std::logic_error("Attempted to overwrite an unspent coin "
112 "(when possible_overwrite is false)");
113 }
114 // If the coin exists in this cache as a spent coin and is DIRTY, then
115 // its spentness hasn't been flushed to the parent cache. We're
116 // re-adding the coin to this cache now but we can't mark it as FRESH.
117 // If we mark it FRESH and then spend it before the cache is flushed
118 // we would remove it from this cache and would never flush spentness
119 // to the parent cache.
120 //
121 // Re-adding a spent coin can happen in the case of a re-org (the coin
122 // is 'spent' when the block adding it is disconnected and then
123 // re-added when it is also added in a newly connected block).
124 //
125 // If the coin doesn't exist in the current cache, or is spent but not
126 // DIRTY, then it can be marked FRESH.
127 fresh = !it->second.IsDirty();
128 }
129 if (!inserted) {
130 Assume(TrySub(m_dirty_count, it->second.IsDirty()));
131 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
132 }
133 it->second.coin = std::move(coin);
136 if (fresh) {
138 }
139 cachedCoinsUsage += it->second.coin.DynamicMemoryUsage();
140 TRACE5(utxocache, add, outpoint.GetTxId().data(), outpoint.GetN(),
141 coin.GetHeight(), coin.GetTxOut().nValue.ToString().c_str(),
142 coin.IsCoinBase());
143}
144
146 Coin &&coin) {
147 const auto mem_usage{coin.DynamicMemoryUsage()};
148 auto [it, inserted] =
149 cacheCoins.try_emplace(std::move(outpoint), std::move(coin));
150 if (inserted) {
153 cachedCoinsUsage += mem_usage;
154 }
155}
156
157void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight,
158 bool check_for_overwrite) {
159 bool fCoinbase = tx.IsCoinBase();
160 const TxId txid = tx.GetId();
161 for (size_t i = 0; i < tx.vout.size(); ++i) {
162 const COutPoint outpoint(txid, i);
163 bool overwrite =
164 check_for_overwrite ? cache.HaveCoin(outpoint) : fCoinbase;
165 // Coinbase transactions can always be overwritten,
166 // in order to correctly deal with the pre-BIP30 occurrences of
167 // duplicate coinbase transactions.
168 cache.AddCoin(outpoint, Coin(tx.vout[i], nHeight, fCoinbase),
169 overwrite);
170 }
171}
172
173bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin *moveout) {
174 CCoinsMap::iterator it = FetchCoin(outpoint);
175 if (it == cacheCoins.end()) {
176 return false;
177 }
178 Assume(TrySub(m_dirty_count, it->second.IsDirty()));
179 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
180 TRACE5(utxocache, spent, outpoint.GetTxId().data(), outpoint.GetN(),
181 it->second.coin.GetHeight(),
182 it->second.coin.GetTxOut().nValue.ToString().c_str(),
183 it->second.coin.IsCoinBase());
184 if (moveout) {
185 *moveout = std::move(it->second.coin);
186 }
187 if (it->second.IsFresh()) {
188 cacheCoins.erase(it);
189 } else {
192 it->second.coin.Clear();
193 }
194 return true;
195}
196
197static const Coin coinEmpty;
198
199const Coin &CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
200 CCoinsMap::const_iterator it = FetchCoin(outpoint);
201 if (it == cacheCoins.end()) {
202 return coinEmpty;
203 }
204 return it->second.coin;
205}
206
207bool CCoinsViewCache::HaveCoin(const COutPoint &outpoint) const {
208 CCoinsMap::const_iterator it = FetchCoin(outpoint);
209 return it != cacheCoins.end() && !it->second.coin.IsSpent();
210}
211
212bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
213 CCoinsMap::const_iterator it = cacheCoins.find(outpoint);
214 return (it != cacheCoins.end() && !it->second.coin.IsSpent());
215}
216
218 if (hashBlock.IsNull()) {
220 }
221 return hashBlock;
222}
223
224void CCoinsViewCache::SetBestBlock(const BlockHash &hashBlockIn) {
225 hashBlock = hashBlockIn;
226}
227
229 const BlockHash &hashBlockIn) {
230 for (auto it{cursor.Begin()}; it != cursor.End();
231 it = cursor.NextAndMaybeErase(*it)) {
232 if (!it->second.IsDirty()) {
233 // TODO a cursor can only contain dirty entries
234 continue;
235 }
236 auto [itUs, inserted]{cacheCoins.try_emplace(it->first)};
237 if (inserted) {
238 if (it->second.IsFresh() && it->second.coin.IsSpent()) {
239 // TODO fresh coins should have been removed at spend
240 cacheCoins.erase(itUs);
241 } else {
242 // The parent cache does not have an entry, while the child
243 // cache does. Move the data up and mark it as dirty.
244 CCoinsCacheEntry &entry{itUs->second};
245 assert(entry.coin.DynamicMemoryUsage() == 0);
246 if (cursor.WillErase(*it)) {
247 // Since this entry will be erased,
248 // we can move the coin into us instead of copying it
249 entry.coin = std::move(it->second.coin);
250 } else {
251 entry.coin = it->second.coin;
252 }
255 cachedCoinsUsage += entry.coin.DynamicMemoryUsage();
256 // We can mark it FRESH in the parent if it was FRESH in the
257 // child. Otherwise it might have just been flushed from the
258 // parent's cache and already exist in the grandparent
259 if (it->second.IsFresh()) {
261 }
262 }
263 } else {
264 // Found the entry in the parent cache
265 if (it->second.IsFresh() && !itUs->second.coin.IsSpent()) {
266 // The coin was marked FRESH in the child cache, but the coin
267 // exists in the parent cache. If this ever happens, it means
268 // the FRESH flag was misapplied and there is a logic error in
269 // the calling code.
270 throw std::logic_error("FRESH flag misapplied to coin that "
271 "exists in parent cache");
272 }
273
274 if (itUs->second.IsFresh() && it->second.coin.IsSpent()) {
275 // The grandparent cache does not have an entry, and the coin
276 // has been spent. We can just delete it from the parent cache.
277 Assume(TrySub(m_dirty_count, itUs->second.IsDirty()));
279 itUs->second.coin.DynamicMemoryUsage()));
280 cacheCoins.erase(itUs);
281 } else {
282 // A normal modification.
284 itUs->second.coin.DynamicMemoryUsage()));
285 if (cursor.WillErase(*it)) {
286 // Since this entry will be erased,
287 // we can move the coin into us instead of copying it
288 itUs->second.coin = std::move(it->second.coin);
289 } else {
290 itUs->second.coin = it->second.coin;
291 }
292 cachedCoinsUsage += itUs->second.coin.DynamicMemoryUsage();
293 if (!itUs->second.IsDirty()) {
296 }
297 // NOTE: It isn't safe to mark the coin as FRESH in the parent
298 // cache. If it already existed and was spent in the parent
299 // cache then marking it FRESH would prevent that spentness
300 // from being flushed to the grandparent.
301 }
302 }
303 }
304 SetBestBlock(hashBlockIn);
305}
306
307void CCoinsViewCache::Flush(bool reallocate_cache) {
309 /*will_erase=*/true)};
310 base->BatchWrite(cursor, hashBlock);
311 Assume(m_dirty_count == 0);
312 cacheCoins.clear();
313 if (reallocate_cache) {
315 }
317}
318
321 /*will_erase=*/false)};
322 base->BatchWrite(cursor, hashBlock);
323 Assume(m_dirty_count == 0);
324 if (m_sentinel.second.Next() != &m_sentinel) {
325 /* BatchWrite must clear flags of all entries */
326 throw std::logic_error("Not all unspent flagged entries were cleared");
327 }
328}
329
330void CCoinsViewCache::Reset() noexcept {
331 cacheCoins.clear();
333 m_dirty_count = 0;
335}
336
337void CCoinsViewCache::Uncache(const COutPoint &outpoint) {
338 CCoinsMap::iterator it = cacheCoins.find(outpoint);
339 if (it != cacheCoins.end() && !it->second.IsDirty()) {
340 Assume(TrySub(cachedCoinsUsage, it->second.coin.DynamicMemoryUsage()));
341 TRACE5(utxocache, uncache, outpoint.GetTxId().data(), outpoint.GetN(),
342 it->second.coin.GetHeight(),
343 it->second.coin.GetTxOut().nValue.ToString().c_str(),
344 it->second.coin.IsCoinBase());
345 cacheCoins.erase(it);
346 }
347}
348
349unsigned int CCoinsViewCache::GetCacheSize() const {
350 return cacheCoins.size();
351}
352
353bool CCoinsViewCache::HaveInputs(const CTransaction &tx) const {
354 if (tx.IsCoinBase()) {
355 return true;
356 }
357
358 for (size_t i = 0; i < tx.vin.size(); i++) {
359 if (!HaveCoin(tx.vin[i].prevout)) {
360 return false;
361 }
362 }
363
364 return true;
365}
366
368 // Cache should be empty when we're calling this.
369 assert(cacheCoins.size() == 0);
370 cacheCoins.~CCoinsMap();
371 m_cache_coins_memory_resource.~CCoinsMapMemoryResource();
373 ::new (&cacheCoins)
374 CCoinsMap{0, SaltedOutpointHasher{/*deterministic=*/m_deterministic},
375 CCoinsMap::key_equal{}, &m_cache_coins_memory_resource};
376}
377
379 size_t recomputed_usage = 0;
380 size_t count_dirty = 0;
381 for (const auto &[_, entry] : cacheCoins) {
382 if (entry.coin.IsSpent()) {
383 // A spent coin must be dirty and cannot be fresh
384 assert(entry.IsDirty() && !entry.IsFresh());
385 } else {
386 // An unspent coin must not be fresh if not dirty
387 assert(entry.IsDirty() || !entry.IsFresh());
388 }
389
390 // Recompute cachedCoinsUsage.
391 recomputed_usage += entry.coin.DynamicMemoryUsage();
392
393 // Count the number of entries we expect in the linked list.
394 if (entry.IsDirty()) {
395 ++count_dirty;
396 }
397 }
398 // Iterate over the linked list of flagged entries.
399 size_t count_linked = 0;
400 for (auto it = m_sentinel.second.Next(); it != &m_sentinel;
401 it = it->second.Next()) {
402 // Verify linked list integrity.
403 assert(it->second.Next()->second.Prev() == it);
404 assert(it->second.Prev()->second.Next() == it);
405 // Verify they are actually flagged.
406 assert(it->second.IsDirty());
407 // Count the number of entries actually in the list.
408 ++count_linked;
409 }
410 assert(count_dirty == count_linked && count_dirty == m_dirty_count);
411 assert(recomputed_usage == cachedCoinsUsage);
412}
413
414// TODO: merge with similar definition in undo.h.
415static const size_t MAX_OUTPUTS_PER_TX =
417
418const Coin &AccessByTxid(const CCoinsViewCache &view, const TxId &txid) {
419 for (uint32_t n = 0; n < MAX_OUTPUTS_PER_TX; n++) {
420 const Coin &alternate = view.AccessCoin(COutPoint(txid, n));
421 if (!alternate.IsSpent()) {
422 return alternate;
423 }
424 }
425
426 return coinEmpty;
427}
428
429template <typename ReturnType, typename Func>
430static ReturnType
432 const std::vector<std::function<void()>> &err_callbacks) {
433 try {
434 return func();
435 } catch (const std::runtime_error &e) {
436 for (const auto &f : err_callbacks) {
437 f();
438 }
439 LogError("Error reading from database: %s\n", e.what());
440 // Starting the shutdown sequence and returning false to the caller
441 // would be interpreted as 'entry not found' (as opposed to unable to
442 // read data), and could lead to invalid interpretation. Just exit
443 // immediately, as we can't continue anyway, and all writes should be
444 // atomic.
445 std::abort();
446 }
447}
448
449std::optional<Coin>
450CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint) const {
451 return ExecuteBackedWrapper<std::optional<Coin>>(
452 [&]() { return CCoinsViewBacked::GetCoin(outpoint); }, m_err_callbacks);
453}
454
455bool CCoinsViewErrorCatcher::HaveCoin(const COutPoint &outpoint) const {
456 return ExecuteBackedWrapper<bool>(
457 [&]() { return CCoinsViewBacked::HaveCoin(outpoint); },
459}
#define Assert(val)
Identity function.
Definition: check.h:87
#define Assume(val)
Assume is the identity function.
Definition: check.h:100
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:319
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:97
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:217
CCoinsMapMemoryResource m_cache_coins_memory_resource
Definition: coins.h:368
bool SpendCoin(const COutPoint &outpoint, Coin *moveto=nullptr)
Spend a coin.
Definition: coins.cpp:173
void Uncache(const COutPoint &outpoint)
Removes the UTXO with the given outpoint from the cache, if it is not modified.
Definition: coins.cpp:337
void BatchWrite(CoinsViewCacheCursor &cursor, const BlockHash &hashBlock) override
Do a bulk modification (multiple Coin changes + BestBlock change).
Definition: coins.cpp:228
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:353
void SetBestBlock(const BlockHash &hashBlock)
Definition: coins.cpp:224
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:307
void Reset() noexcept
Discard all modifications made to this cache without flushing to the base view.
Definition: coins.cpp:330
unsigned int GetCacheSize() const
Size of the cache (in number of transaction outputs)
Definition: coins.cpp:349
size_t cachedCoinsUsage
Definition: coins.h:376
CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const
Definition: coins.cpp:74
bool HaveCoinInCache(const COutPoint &outpoint) const
Check if we have the given utxo already loaded in this cache.
Definition: coins.cpp:212
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:69
void EmplaceCoinInternalDANGER(COutPoint &&outpoint, Coin &&coin)
Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty.
Definition: coins.cpp:145
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:207
void SanityCheck() const
Run an internal sanity check on the cache data structure.
Definition: coins.cpp:378
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:89
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Definition: coins.cpp:199
void ReallocateCache()
Force a reallocation of the cache map.
Definition: coins.cpp:367
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:450
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:455
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
constexpr bool IsNull() const
Definition: uint256.h:40
static const uint256 ZERO
Definition: uint256.h:132
static const size_t MAX_OUTPUTS_PER_TX
Definition: coins.cpp:415
const Coin & AccessByTxid(const CCoinsViewCache &view, const TxId &txid)
Utility function to find any unspent output with a given txid.
Definition: coins.cpp:418
static const Coin coinEmpty
Definition: coins.cpp:197
static ReturnType ExecuteBackedWrapper(Func func, const std::vector< std::function< void()> > &err_callbacks)
Definition: coins.cpp:431
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:157
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:48
size_t GetSerializeSize(const T &t)
Definition: serialize.h:1264
std::string ToString() const
Definition: amount.cpp:29
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())