LCOV - code coverage report
Current view: top level - src - context.h (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 3 3 100.0 %
Date: 2026-06-25 07:23:51 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2022-2025 The Dash 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_CONTEXT_H
       6             : #define BITCOIN_CONTEXT_H
       7             : 
       8             : #include <functional>
       9             : #include <variant>
      10             : 
      11             : class ArgsManager;
      12             : class ChainstateManager;
      13             : class CTxMemPool;
      14             : class CBlockPolicyEstimator;
      15             : struct LLMQContext;
      16             : namespace node {
      17             : struct NodeContext;
      18             : } // namespace node
      19             : namespace wallet {
      20             : struct WalletContext;
      21             : } // namespace wallet
      22             : 
      23             : using CoreContext = std::variant<std::monostate,
      24             :                                  std::reference_wrapper<ArgsManager>,
      25             :                                  std::reference_wrapper<node::NodeContext>,
      26             :                                  std::reference_wrapper<wallet::WalletContext>,
      27             :                                  std::reference_wrapper<CTxMemPool>,
      28             :                                  std::reference_wrapper<ChainstateManager>,
      29             :                                  std::reference_wrapper<CBlockPolicyEstimator>,
      30             :                                  std::reference_wrapper<LLMQContext>>;
      31             : 
      32             : template<typename T>
      33        6229 : T* GetContext(const CoreContext& context) noexcept
      34             : {
      35       12458 :     return std::holds_alternative<std::reference_wrapper<T>>(context)
      36        6229 :                 ? &std::get<std::reference_wrapper<T>>(context).get()
      37             :                 : nullptr;
      38             : }
      39             : 
      40             : #endif // BITCOIN_CONTEXT_H

Generated by: LCOV version 1.16