LCOV - code coverage report
Current view: top level - src/node - chainstate.h (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 10 10 100.0 %
Date: 2023-11-10 23:46:46 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2021-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                 :            : #ifndef BITCOIN_NODE_CHAINSTATE_H
       6                 :            : #define BITCOIN_NODE_CHAINSTATE_H
       7                 :            : 
       8                 :            : #include <util/translation.h>
       9                 :            : #include <validation.h>
      10                 :            : 
      11                 :            : #include <cstdint>
      12                 :            : #include <functional>
      13                 :            : #include <tuple>
      14                 :            : 
      15                 :            : class CTxMemPool;
      16                 :            : 
      17                 :            : namespace node {
      18                 :            : 
      19                 :            : struct CacheSizes;
      20                 :            : 
      21                 :          1 : struct ChainstateLoadOptions {
      22                 :          1 :     CTxMemPool* mempool{nullptr};
      23                 :          1 :     bool block_tree_db_in_memory{false};
      24                 :          1 :     bool coins_db_in_memory{false};
      25                 :          1 :     bool reindex{false};
      26                 :          1 :     bool reindex_chainstate{false};
      27                 :          1 :     bool prune{false};
      28                 :            :     //! Setting require_full_verification to true will require all checks at
      29                 :            :     //! check_level (below) to succeed for loading to succeed. Setting it to
      30                 :            :     //! false will skip checks if cache is not big enough to run them, so may be
      31                 :            :     //! helpful for running with a small cache.
      32                 :          1 :     bool require_full_verification{true};
      33                 :          1 :     int64_t check_blocks{DEFAULT_CHECKBLOCKS};
      34                 :          1 :     int64_t check_level{DEFAULT_CHECKLEVEL};
      35                 :            :     std::function<bool()> check_interrupt;
      36                 :            :     std::function<void()> coins_error_cb;
      37                 :            : };
      38                 :            : 
      39                 :            : //! Chainstate load status. Simple applications can just check for the success
      40                 :            : //! case, and treat other cases as errors. More complex applications may want to
      41                 :            : //! try reindexing in the generic failure case, and pass an interrupt callback
      42                 :            : //! and exit cleanly in the interrupted case.
      43                 :            : enum class ChainstateLoadStatus {
      44                 :            :     SUCCESS,
      45                 :            :     FAILURE, //!< Generic failure which reindexing may fix
      46                 :            :     FAILURE_FATAL, //!< Fatal error which should not prompt to reindex
      47                 :            :     FAILURE_INCOMPATIBLE_DB,
      48                 :            :     FAILURE_INSUFFICIENT_DBCACHE,
      49                 :            :     INTERRUPTED,
      50                 :            : };
      51                 :            : 
      52                 :            : //! Chainstate load status code and optional error string.
      53                 :            : using ChainstateLoadResult = std::tuple<ChainstateLoadStatus, bilingual_str>;
      54                 :            : 
      55                 :            : /** This sequence can have 4 types of outcomes:
      56                 :            :  *
      57                 :            :  *  1. Success
      58                 :            :  *  2. Shutdown requested
      59                 :            :  *    - nothing failed but a shutdown was triggered in the middle of the
      60                 :            :  *      sequence
      61                 :            :  *  3. Soft failure
      62                 :            :  *    - a failure that might be recovered from with a reindex
      63                 :            :  *  4. Hard failure
      64                 :            :  *    - a failure that definitively cannot be recovered from with a reindex
      65                 :            :  *
      66                 :            :  *  LoadChainstate returns a (status code, error string) tuple.
      67                 :            :  */
      68                 :            : ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
      69                 :            :                                     const ChainstateLoadOptions& options);
      70                 :            : ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const ChainstateLoadOptions& options);
      71                 :            : } // namespace node
      72                 :            : 
      73                 :            : #endif // BITCOIN_NODE_CHAINSTATE_H

Generated by: LCOV version 1.14