2024-10-04 22:06:43 +02:00
|
|
|
// Copyright (c) 2022-2024 The Dash Core developers
|
2022-10-22 19:18:03 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_CONTEXT_H
|
|
|
|
#define BITCOIN_CONTEXT_H
|
|
|
|
|
2024-07-11 17:20:12 +02:00
|
|
|
#include <functional>
|
2022-10-22 19:18:03 +02:00
|
|
|
#include <variant>
|
|
|
|
|
2024-09-08 17:58:14 +02:00
|
|
|
class ArgsManager;
|
2022-10-22 19:18:03 +02:00
|
|
|
class ChainstateManager;
|
|
|
|
class CTxMemPool;
|
2023-02-22 08:53:20 +01:00
|
|
|
class CBlockPolicyEstimator;
|
2022-11-07 19:09:44 +01:00
|
|
|
struct LLMQContext;
|
2022-10-22 19:18:03 +02:00
|
|
|
struct NodeContext;
|
|
|
|
struct WalletContext;
|
|
|
|
|
2024-07-11 17:20:12 +02:00
|
|
|
using CoreContext = std::variant<std::monostate,
|
2024-09-08 17:58:14 +02:00
|
|
|
std::reference_wrapper<ArgsManager>,
|
2022-10-22 19:18:03 +02:00
|
|
|
std::reference_wrapper<NodeContext>,
|
|
|
|
std::reference_wrapper<WalletContext>,
|
|
|
|
std::reference_wrapper<CTxMemPool>,
|
2022-11-07 19:09:44 +01:00
|
|
|
std::reference_wrapper<ChainstateManager>,
|
2023-02-22 08:53:20 +01:00
|
|
|
std::reference_wrapper<CBlockPolicyEstimator>,
|
2022-11-07 19:09:44 +01:00
|
|
|
std::reference_wrapper<LLMQContext>>;
|
2022-10-22 19:18:03 +02:00
|
|
|
|
|
|
|
template<typename T>
|
2023-07-25 10:58:32 +02:00
|
|
|
T* GetContext(const CoreContext& context) noexcept
|
2022-10-22 19:18:03 +02:00
|
|
|
{
|
2023-07-25 10:58:32 +02:00
|
|
|
return std::holds_alternative<std::reference_wrapper<T>>(context)
|
|
|
|
? &std::get<std::reference_wrapper<T>>(context).get()
|
2022-10-22 19:18:03 +02:00
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
2021-11-12 11:19:44 +01:00
|
|
|
#endif // BITCOIN_CONTEXT_H
|