LCOV - code coverage report
Current view: top level - src/node - chainstate.h (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 100.0 % 1 1
Test Date: 2024-08-28 04:44:32 Functions: - 0 0
Branches: 50.0 % 2 1

             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         [ +  - ]:         330 : struct ChainstateLoadOptions {
      22                 :             :     CTxMemPool* mempool{nullptr};
      23                 :             :     bool block_tree_db_in_memory{false};
      24                 :             :     bool coins_db_in_memory{false};
      25                 :             :     // Whether to wipe the block tree database when loading it. If set, this
      26                 :             :     // will also set a reindexing flag so any existing block data files will be
      27                 :             :     // scanned and added to the database.
      28                 :             :     bool wipe_block_tree_db{false};
      29                 :             :     // Whether to wipe the chainstate database when loading it. If set, this
      30                 :             :     // will cause the chainstate database to be rebuilt starting from genesis.
      31                 :             :     bool wipe_chainstate_db{false};
      32                 :             :     bool prune{false};
      33                 :             :     //! Setting require_full_verification to true will require all checks at
      34                 :             :     //! check_level (below) to succeed for loading to succeed. Setting it to
      35                 :             :     //! false will skip checks if cache is not big enough to run them, so may be
      36                 :             :     //! helpful for running with a small cache.
      37                 :             :     bool require_full_verification{true};
      38                 :             :     int64_t check_blocks{DEFAULT_CHECKBLOCKS};
      39                 :             :     int64_t check_level{DEFAULT_CHECKLEVEL};
      40                 :             :     std::function<void()> coins_error_cb;
      41                 :             : };
      42                 :             : 
      43                 :             : //! Chainstate load status. Simple applications can just check for the success
      44                 :             : //! case, and treat other cases as errors. More complex applications may want to
      45                 :             : //! try reindexing in the generic failure case, and pass an interrupt callback
      46                 :             : //! and exit cleanly in the interrupted case.
      47                 :             : enum class ChainstateLoadStatus {
      48                 :             :     SUCCESS,
      49                 :             :     FAILURE, //!< Generic failure which reindexing may fix
      50                 :             :     FAILURE_FATAL, //!< Fatal error which should not prompt to reindex
      51                 :             :     FAILURE_INCOMPATIBLE_DB,
      52                 :             :     FAILURE_INSUFFICIENT_DBCACHE,
      53                 :             :     INTERRUPTED,
      54                 :             : };
      55                 :             : 
      56                 :             : //! Chainstate load status code and optional error string.
      57                 :             : using ChainstateLoadResult = std::tuple<ChainstateLoadStatus, bilingual_str>;
      58                 :             : 
      59                 :             : /** This sequence can have 4 types of outcomes:
      60                 :             :  *
      61                 :             :  *  1. Success
      62                 :             :  *  2. Shutdown requested
      63                 :             :  *    - nothing failed but a shutdown was triggered in the middle of the
      64                 :             :  *      sequence
      65                 :             :  *  3. Soft failure
      66                 :             :  *    - a failure that might be recovered from with a reindex
      67                 :             :  *  4. Hard failure
      68                 :             :  *    - a failure that definitively cannot be recovered from with a reindex
      69                 :             :  *
      70                 :             :  *  LoadChainstate returns a (status code, error string) tuple.
      71                 :             :  */
      72                 :             : ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
      73                 :             :                                     const ChainstateLoadOptions& options);
      74                 :             : ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const ChainstateLoadOptions& options);
      75                 :             : } // namespace node
      76                 :             : 
      77                 :             : #endif // BITCOIN_NODE_CHAINSTATE_H
        

Generated by: LCOV version 2.0-1