2022-10-22 19:18:03 +02:00
|
|
|
// Copyright (c) 2022 The Dash Core developers
|
|
|
|
// 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
|
|
|
|
|
|
|
|
#include <variant>
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
using CoreContext = std::variant<std::nullopt_t,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // BITCOIN_CONTEXT_VARIANT_H
|