LCOV - code coverage report
Current view: top level - src - coins.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 100 231 43.3 %
Date: 2023-11-10 23:46:46 Functions: 19 46 41.3 %
Branches: 36 164 22.0 %

           Branch data     Line data    Source code
       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                 :            : 
       7                 :            : #include <consensus/consensus.h>
       8                 :            : #include <logging.h>
       9                 :            : #include <random.h>
      10                 :            : #include <util/trace.h>
      11                 :            : #include <version.h>
      12                 :            : 
      13                 :          0 : bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; }
      14                 :          0 : uint256 CCoinsView::GetBestBlock() const { return uint256(); }
      15                 :          0 : std::vector<uint256> CCoinsView::GetHeadBlocks() const { return std::vector<uint256>(); }
      16                 :          0 : bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, bool erase) { return false; }
      17                 :          0 : std::unique_ptr<CCoinsViewCursor> CCoinsView::Cursor() const { return nullptr; }
      18                 :            : 
      19                 :          0 : bool CCoinsView::HaveCoin(const COutPoint &outpoint) const
      20                 :            : {
      21                 :          0 :     Coin coin;
      22         [ #  # ]:          0 :     return GetCoin(outpoint, coin);
      23                 :          0 : }
      24                 :            : 
      25                 :      22586 : CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { }
      26                 :       9984 : bool CCoinsViewBacked::GetCoin(const COutPoint &outpoint, Coin &coin) const { return base->GetCoin(outpoint, coin); }
      27                 :          0 : bool CCoinsViewBacked::HaveCoin(const COutPoint &outpoint) const { return base->HaveCoin(outpoint); }
      28                 :          3 : uint256 CCoinsViewBacked::GetBestBlock() const { return base->GetBestBlock(); }
      29                 :          0 : std::vector<uint256> CCoinsViewBacked::GetHeadBlocks() const { return base->GetHeadBlocks(); }
      30                 :          0 : void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; }
      31                 :          0 : bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, bool erase) { return base->BatchWrite(mapCoins, hashBlock, erase); }
      32                 :          0 : std::unique_ptr<CCoinsViewCursor> CCoinsViewBacked::Cursor() const { return base->Cursor(); }
      33                 :          0 : size_t CCoinsViewBacked::EstimateSize() const { return base->EstimateSize(); }
      34                 :            : 
      35 [ +  - ][ +  - ]:        908 : CCoinsViewCache::CCoinsViewCache(CCoinsView* baseIn, bool deterministic) :
      36                 :        908 :     CCoinsViewBacked(baseIn), m_deterministic(deterministic),
      37 [ +  - ][ +  - ]:        454 :     cacheCoins(0, SaltedOutpointHasher(/*deterministic=*/deterministic), CCoinsMap::key_equal{}, &m_cache_coins_memory_resource)
      38                 :        908 : {}
      39                 :            : 
      40                 :       1057 : size_t CCoinsViewCache::DynamicMemoryUsage() const {
      41                 :       1057 :     return memusage::DynamicUsage(cacheCoins) + cachedCoinsUsage;
      42                 :            : }
      43                 :            : 
      44                 :      41305 : CCoinsMap::iterator CCoinsViewCache::FetchCoin(const COutPoint &outpoint) const {
      45                 :      41305 :     CCoinsMap::iterator it = cacheCoins.find(outpoint);
      46         [ +  + ]:      41305 :     if (it != cacheCoins.end())
      47                 :      30721 :         return it;
      48                 :      10584 :     Coin tmp;
      49 [ +  - ][ -  + ]:      10584 :     if (!base->GetCoin(outpoint, tmp))
      50                 :      10584 :         return cacheCoins.end();
      51         [ #  # ]:          0 :     CCoinsMap::iterator ret = cacheCoins.emplace(std::piecewise_construct, std::forward_as_tuple(outpoint), std::forward_as_tuple(std::move(tmp))).first;
      52 [ #  # ][ #  # ]:          0 :     if (ret->second.coin.IsSpent()) {
      53                 :            :         // The parent only has an empty entry for this outpoint; we can consider our
      54                 :            :         // version as fresh.
      55                 :          0 :         ret->second.flags = CCoinsCacheEntry::FRESH;
      56                 :          0 :     }
      57         [ #  # ]:          0 :     cachedCoinsUsage += ret->second.coin.DynamicMemoryUsage();
      58                 :          0 :     return ret;
      59                 :      41305 : }
      60                 :            : 
      61                 :      40705 : bool CCoinsViewCache::GetCoin(const COutPoint &outpoint, Coin &coin) const {
      62                 :      40705 :     CCoinsMap::const_iterator it = FetchCoin(outpoint);
      63         [ +  + ]:      40705 :     if (it != cacheCoins.end()) {
      64                 :      30721 :         coin = it->second.coin;
      65                 :      30721 :         return !coin.IsSpent();
      66                 :            :     }
      67                 :       9984 :     return false;
      68                 :      40705 : }
      69                 :            : 
      70                 :        600 : void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possible_overwrite) {
      71         [ +  - ]:        600 :     assert(!coin.IsSpent());
      72         [ +  + ]:        600 :     if (coin.out.scriptPubKey.IsUnspendable()) return;
      73                 :        300 :     CCoinsMap::iterator it;
      74                 :            :     bool inserted;
      75                 :        300 :     std::tie(it, inserted) = cacheCoins.emplace(std::piecewise_construct, std::forward_as_tuple(outpoint), std::tuple<>());
      76                 :        300 :     bool fresh = false;
      77         [ +  - ]:        300 :     if (!inserted) {
      78                 :          0 :         cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
      79                 :          0 :     }
      80         [ +  - ]:        300 :     if (!possible_overwrite) {
      81         [ #  # ]:          0 :         if (!it->second.coin.IsSpent()) {
      82         [ #  # ]:          0 :             throw std::logic_error("Attempted to overwrite an unspent coin (when possible_overwrite is false)");
      83                 :            :         }
      84                 :            :         // If the coin exists in this cache as a spent coin and is DIRTY, then
      85                 :            :         // its spentness hasn't been flushed to the parent cache. We're
      86                 :            :         // re-adding the coin to this cache now but we can't mark it as FRESH.
      87                 :            :         // If we mark it FRESH and then spend it before the cache is flushed
      88                 :            :         // we would remove it from this cache and would never flush spentness
      89                 :            :         // to the parent cache.
      90                 :            :         //
      91                 :            :         // Re-adding a spent coin can happen in the case of a re-org (the coin
      92                 :            :         // is 'spent' when the block adding it is disconnected and then
      93                 :            :         // re-added when it is also added in a newly connected block).
      94                 :            :         //
      95                 :            :         // If the coin doesn't exist in the current cache, or is spent but not
      96                 :            :         // DIRTY, then it can be marked FRESH.
      97                 :          0 :         fresh = !(it->second.flags & CCoinsCacheEntry::DIRTY);
      98                 :          0 :     }
      99                 :        300 :     it->second.coin = std::move(coin);
     100                 :        300 :     it->second.flags |= CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0);
     101                 :        300 :     cachedCoinsUsage += it->second.coin.DynamicMemoryUsage();
     102                 :            :     TRACE5(utxocache, add,
     103                 :            :            outpoint.hash.data(),
     104                 :            :            (uint32_t)outpoint.n,
     105                 :            :            (uint32_t)it->second.coin.nHeight,
     106                 :            :            (int64_t)it->second.coin.out.nValue,
     107                 :            :            (bool)it->second.coin.IsCoinBase());
     108                 :        600 : }
     109                 :            : 
     110                 :          0 : void CCoinsViewCache::EmplaceCoinInternalDANGER(COutPoint&& outpoint, Coin&& coin) {
     111                 :          0 :     cachedCoinsUsage += coin.DynamicMemoryUsage();
     112                 :          0 :     cacheCoins.emplace(
     113                 :            :         std::piecewise_construct,
     114                 :          0 :         std::forward_as_tuple(std::move(outpoint)),
     115                 :          0 :         std::forward_as_tuple(std::move(coin), CCoinsCacheEntry::DIRTY));
     116                 :          0 : }
     117                 :            : 
     118                 :        300 : void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool check_for_overwrite) {
     119                 :        300 :     bool fCoinbase = tx.IsCoinBase();
     120                 :        300 :     const uint256& txid = tx.GetHash();
     121         [ +  + ]:        900 :     for (size_t i = 0; i < tx.vout.size(); ++i) {
     122         [ -  + ]:        600 :         bool overwrite = check_for_overwrite ? cache.HaveCoin(COutPoint(txid, i)) : fCoinbase;
     123                 :            :         // Coinbase transactions can always be overwritten, in order to correctly
     124                 :            :         // deal with the pre-BIP30 occurrences of duplicate coinbase transactions.
     125         [ +  - ]:        600 :         cache.AddCoin(COutPoint(txid, i), Coin(tx.vout[i], nHeight, fCoinbase), overwrite);
     126                 :        600 :     }
     127                 :        300 : }
     128                 :            : 
     129                 :          0 : bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
     130                 :          0 :     CCoinsMap::iterator it = FetchCoin(outpoint);
     131         [ #  # ]:          0 :     if (it == cacheCoins.end()) return false;
     132                 :          0 :     cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
     133                 :            :     TRACE5(utxocache, spent,
     134                 :            :            outpoint.hash.data(),
     135                 :            :            (uint32_t)outpoint.n,
     136                 :            :            (uint32_t)it->second.coin.nHeight,
     137                 :            :            (int64_t)it->second.coin.out.nValue,
     138                 :            :            (bool)it->second.coin.IsCoinBase());
     139         [ #  # ]:          0 :     if (moveout) {
     140                 :          0 :         *moveout = std::move(it->second.coin);
     141                 :          0 :     }
     142         [ #  # ]:          0 :     if (it->second.flags & CCoinsCacheEntry::FRESH) {
     143                 :          0 :         cacheCoins.erase(it);
     144                 :          0 :     } else {
     145                 :          0 :         it->second.flags |= CCoinsCacheEntry::DIRTY;
     146                 :          0 :         it->second.coin.Clear();
     147                 :            :     }
     148                 :          0 :     return true;
     149                 :          0 : }
     150                 :            : 
     151                 :          2 : static const Coin coinEmpty;
     152                 :            : 
     153                 :          0 : const Coin& CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
     154                 :          0 :     CCoinsMap::const_iterator it = FetchCoin(outpoint);
     155         [ #  # ]:          0 :     if (it == cacheCoins.end()) {
     156                 :          0 :         return coinEmpty;
     157                 :            :     } else {
     158                 :          0 :         return it->second.coin;
     159                 :            :     }
     160                 :          0 : }
     161                 :            : 
     162                 :        600 : bool CCoinsViewCache::HaveCoin(const COutPoint &outpoint) const {
     163                 :        600 :     CCoinsMap::const_iterator it = FetchCoin(outpoint);
     164         [ +  - ]:        600 :     return (it != cacheCoins.end() && !it->second.coin.IsSpent());
     165                 :            : }
     166                 :            : 
     167                 :          0 : bool CCoinsViewCache::HaveCoinInCache(const COutPoint &outpoint) const {
     168                 :          0 :     CCoinsMap::const_iterator it = cacheCoins.find(outpoint);
     169         [ #  # ]:          0 :     return (it != cacheCoins.end() && !it->second.coin.IsSpent());
     170                 :            : }
     171                 :            : 
     172                 :        604 : uint256 CCoinsViewCache::GetBestBlock() const {
     173         [ +  + ]:        604 :     if (hashBlock.IsNull())
     174                 :        304 :         hashBlock = base->GetBestBlock();
     175                 :        604 :     return hashBlock;
     176                 :            : }
     177                 :            : 
     178                 :        151 : void CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
     179                 :        151 :     hashBlock = hashBlockIn;
     180                 :        151 : }
     181                 :            : 
     182                 :        151 : bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn, bool erase) {
     183         [ +  + ]:        301 :     for (CCoinsMap::iterator it = mapCoins.begin();
     184                 :        301 :             it != mapCoins.end();
     185         [ +  - ]:        150 :             it = erase ? mapCoins.erase(it) : std::next(it)) {
     186                 :            :         // Ignore non-dirty entries (optimization).
     187         [ +  - ]:        150 :         if (!(it->second.flags & CCoinsCacheEntry::DIRTY)) {
     188                 :          0 :             continue;
     189                 :            :         }
     190                 :        150 :         CCoinsMap::iterator itUs = cacheCoins.find(it->first);
     191         [ +  - ]:        150 :         if (itUs == cacheCoins.end()) {
     192                 :            :             // The parent cache does not have an entry, while the child cache does.
     193                 :            :             // We can ignore it if it's both spent and FRESH in the child
     194 [ -  + ][ #  # ]:        150 :             if (!(it->second.flags & CCoinsCacheEntry::FRESH && it->second.coin.IsSpent())) {
     195                 :            :                 // Create the coin in the parent cache, move the data up
     196                 :            :                 // and mark it as dirty.
     197                 :        150 :                 CCoinsCacheEntry& entry = cacheCoins[it->first];
     198         [ +  - ]:        150 :                 if (erase) {
     199                 :            :                     // The `move` call here is purely an optimization; we rely on the
     200                 :            :                     // `mapCoins.erase` call in the `for` expression to actually remove
     201                 :            :                     // the entry from the child map.
     202                 :        150 :                     entry.coin = std::move(it->second.coin);
     203                 :        150 :                 } else {
     204                 :          0 :                     entry.coin = it->second.coin;
     205                 :            :                 }
     206                 :        150 :                 cachedCoinsUsage += entry.coin.DynamicMemoryUsage();
     207                 :        150 :                 entry.flags = CCoinsCacheEntry::DIRTY;
     208                 :            :                 // We can mark it FRESH in the parent if it was FRESH in the child
     209                 :            :                 // Otherwise it might have just been flushed from the parent's cache
     210                 :            :                 // and already exist in the grandparent
     211         [ +  - ]:        150 :                 if (it->second.flags & CCoinsCacheEntry::FRESH) {
     212                 :          0 :                     entry.flags |= CCoinsCacheEntry::FRESH;
     213                 :          0 :                 }
     214                 :        150 :             }
     215                 :        150 :         } else {
     216                 :            :             // Found the entry in the parent cache
     217 [ #  # ][ #  # ]:          0 :             if ((it->second.flags & CCoinsCacheEntry::FRESH) && !itUs->second.coin.IsSpent()) {
     218                 :            :                 // The coin was marked FRESH in the child cache, but the coin
     219                 :            :                 // exists in the parent cache. If this ever happens, it means
     220                 :            :                 // the FRESH flag was misapplied and there is a logic error in
     221                 :            :                 // the calling code.
     222         [ #  # ]:          0 :                 throw std::logic_error("FRESH flag misapplied to coin that exists in parent cache");
     223                 :            :             }
     224                 :            : 
     225 [ #  # ][ #  # ]:          0 :             if ((itUs->second.flags & CCoinsCacheEntry::FRESH) && it->second.coin.IsSpent()) {
     226                 :            :                 // The grandparent cache does not have an entry, and the coin
     227                 :            :                 // has been spent. We can just delete it from the parent cache.
     228                 :          0 :                 cachedCoinsUsage -= itUs->second.coin.DynamicMemoryUsage();
     229                 :          0 :                 cacheCoins.erase(itUs);
     230                 :          0 :             } else {
     231                 :            :                 // A normal modification.
     232                 :          0 :                 cachedCoinsUsage -= itUs->second.coin.DynamicMemoryUsage();
     233         [ #  # ]:          0 :                 if (erase) {
     234                 :            :                     // The `move` call here is purely an optimization; we rely on the
     235                 :            :                     // `mapCoins.erase` call in the `for` expression to actually remove
     236                 :            :                     // the entry from the child map.
     237                 :          0 :                     itUs->second.coin = std::move(it->second.coin);
     238                 :          0 :                 } else {
     239                 :          0 :                     itUs->second.coin = it->second.coin;
     240         [ +  - ]:        454 :                 }
     241                 :          0 :                 cachedCoinsUsage += itUs->second.coin.DynamicMemoryUsage();
     242                 :          0 :                 itUs->second.flags |= CCoinsCacheEntry::DIRTY;
     243                 :            :                 // NOTE: It isn't safe to mark the coin as FRESH in the parent
     244                 :        454 :                 // cache. If it already existed and was spent in the parent
     245                 :            :                 // cache then marking it FRESH would prevent that spentness
     246                 :            :                 // from being flushed to the grandparent.
     247                 :            :             }
     248                 :            :         }
     249                 :        150 :     }
     250                 :        151 :     hashBlock = hashBlockIn;
     251                 :        151 :     return true;
     252                 :          0 : }
     253                 :            : 
     254                 :        151 : bool CCoinsViewCache::Flush() {
     255                 :        151 :     bool fOk = base->BatchWrite(cacheCoins, hashBlock, /*erase=*/true);
     256         [ -  + ]:        151 :     if (fOk) {
     257         [ +  - ]:        151 :         if (!cacheCoins.empty()) {
     258                 :            :             /* BatchWrite must erase all cacheCoins elements when erase=true. */
     259         [ #  # ]:          0 :             throw std::logic_error("Not all cached coins were erased");
     260                 :            :         }
     261                 :        151 :         ReallocateCache();
     262                 :        151 :     }
     263                 :        151 :     cachedCoinsUsage = 0;
     264                 :        151 :     return fOk;
     265                 :          0 : }
     266                 :            : 
     267                 :          0 : bool CCoinsViewCache::Sync()
     268                 :            : {
     269                 :          0 :     bool fOk = base->BatchWrite(cacheCoins, hashBlock, /*erase=*/false);
     270                 :            :     // Instead of clearing `cacheCoins` as we would in Flush(), just clear the
     271                 :            :     // FRESH/DIRTY flags of any coin that isn't spent.
     272         [ #  # ]:          0 :     for (auto it = cacheCoins.begin(); it != cacheCoins.end(); ) {
     273         [ #  # ]:          0 :         if (it->second.coin.IsSpent()) {
     274                 :          0 :             cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
     275                 :          0 :             it = cacheCoins.erase(it);
     276                 :          0 :         } else {
     277                 :          0 :             it->second.flags = 0;
     278                 :          0 :             ++it;
     279                 :            :         }
     280                 :            :     }
     281                 :          0 :     return fOk;
     282                 :            : }
     283                 :            : 
     284                 :          0 : void CCoinsViewCache::Uncache(const COutPoint& hash)
     285                 :            : {
     286                 :          0 :     CCoinsMap::iterator it = cacheCoins.find(hash);
     287 [ #  # ][ #  # ]:          0 :     if (it != cacheCoins.end() && it->second.flags == 0) {
     288                 :          0 :         cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
     289                 :            :         TRACE5(utxocache, uncache,
     290                 :            :                hash.hash.data(),
     291                 :            :                (uint32_t)hash.n,
     292                 :            :                (uint32_t)it->second.coin.nHeight,
     293                 :            :                (int64_t)it->second.coin.out.nValue,
     294                 :            :                (bool)it->second.coin.IsCoinBase());
     295                 :          0 :         cacheCoins.erase(it);
     296                 :          0 :     }
     297                 :          0 : }
     298                 :            : 
     299                 :        604 : unsigned int CCoinsViewCache::GetCacheSize() const {
     300                 :        604 :     return cacheCoins.size();
     301                 :            : }
     302                 :            : 
     303                 :          0 : bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
     304                 :            : {
     305         [ #  # ]:          0 :     if (!tx.IsCoinBase()) {
     306         [ #  # ]:          0 :         for (unsigned int i = 0; i < tx.vin.size(); i++) {
     307         [ #  # ]:          0 :             if (!HaveCoin(tx.vin[i].prevout)) {
     308                 :          0 :                 return false;
     309                 :            :             }
     310                 :          0 :         }
     311                 :          0 :     }
     312                 :          0 :     return true;
     313                 :          0 : }
     314                 :            : 
     315                 :        151 : void CCoinsViewCache::ReallocateCache()
     316                 :            : {
     317                 :            :     // Cache should be empty when we're calling this.
     318         [ +  - ]:        151 :     assert(cacheCoins.size() == 0);
     319                 :        151 :     cacheCoins.~CCoinsMap();
     320                 :        151 :     m_cache_coins_memory_resource.~CCoinsMapMemoryResource();
     321                 :        151 :     ::new (&m_cache_coins_memory_resource) CCoinsMapMemoryResource{};
     322                 :        151 :     ::new (&cacheCoins) CCoinsMap{0, SaltedOutpointHasher{/*deterministic=*/m_deterministic}, CCoinsMap::key_equal{}, &m_cache_coins_memory_resource};
     323                 :        151 : }
     324                 :            : 
     325                 :          0 : void CCoinsViewCache::SanityCheck() const
     326                 :            : {
     327                 :          0 :     size_t recomputed_usage = 0;
     328         [ #  # ]:          0 :     for (const auto& [_, entry] : cacheCoins) {
     329                 :          0 :         unsigned attr = 0;
     330         [ #  # ]:          0 :         if (entry.flags & CCoinsCacheEntry::DIRTY) attr |= 1;
     331         [ #  # ]:          0 :         if (entry.flags & CCoinsCacheEntry::FRESH) attr |= 2;
     332         [ #  # ]:          0 :         if (entry.coin.IsSpent()) attr |= 4;
     333                 :            :         // Only 5 combinations are possible.
     334 [ #  # ][ #  # ]:          0 :         assert(attr != 2 && attr != 4 && attr != 7);
                 [ #  # ]
     335                 :            : 
     336                 :            :         // Recompute cachedCoinsUsage.
     337                 :          0 :         recomputed_usage += entry.coin.DynamicMemoryUsage();
     338                 :            :     }
     339         [ #  # ]:          0 :     assert(recomputed_usage == cachedCoinsUsage);
     340                 :          0 : }
     341                 :            : 
     342         [ +  - ]:          2 : static const size_t MIN_TRANSACTION_OUTPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxOut(), PROTOCOL_VERSION);
     343                 :          2 : static const size_t MAX_OUTPUTS_PER_BLOCK = MAX_BLOCK_WEIGHT / MIN_TRANSACTION_OUTPUT_WEIGHT;
     344                 :            : 
     345                 :          0 : const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
     346                 :            : {
     347                 :          0 :     COutPoint iter(txid, 0);
     348         [ #  # ]:          0 :     while (iter.n < MAX_OUTPUTS_PER_BLOCK) {
     349                 :          0 :         const Coin& alternate = view.AccessCoin(iter);
     350         [ #  # ]:          0 :         if (!alternate.IsSpent()) return alternate;
     351                 :          0 :         ++iter.n;
     352                 :            :     }
     353                 :          0 :     return coinEmpty;
     354                 :          0 : }
     355                 :            : 
     356                 :            : template <typename Func>
     357                 :       9984 : static bool ExecuteBackedWrapper(Func func, const std::vector<std::function<void()>>& err_callbacks)
     358                 :            : {
     359                 :            :     try {
     360 [ +  - ][ #  # ]:       9984 :         return func();
     361 [ #  # ][ #  # ]:          0 :     } catch(const std::runtime_error& e) {
     362 [ #  # ][ #  # ]:          0 :         for (const auto& f : err_callbacks) {
     363 [ #  # ][ #  # ]:          0 :             f();
     364                 :            :         }
     365 [ #  # ][ #  # ]:          0 :         LogPrintf("Error reading from database: %s\n", e.what());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     366                 :            :         // Starting the shutdown sequence and returning false to the caller would be
     367                 :            :         // interpreted as 'entry not found' (as opposed to unable to read data), and
     368                 :            :         // could lead to invalid interpretation. Just exit immediately, as we can't
     369                 :            :         // continue anyway, and all writes should be atomic.
     370                 :          0 :         std::abort();
     371 [ #  # ][ #  # ]:          0 :     }
     372                 :          0 : }
     373                 :            : 
     374                 :       9984 : bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) const {
     375                 :      19968 :     return ExecuteBackedWrapper([&]() { return CCoinsViewBacked::GetCoin(outpoint, coin); }, m_err_callbacks);
     376                 :            : }
     377                 :            : 
     378                 :          0 : bool CCoinsViewErrorCatcher::HaveCoin(const COutPoint &outpoint) const {
     379                 :          0 :     return ExecuteBackedWrapper([&]() { return CCoinsViewBacked::HaveCoin(outpoint); }, m_err_callbacks);
     380                 :            : }

Generated by: LCOV version 1.14