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>
|
|
|
|
T* GetContext(const CoreContext& ctx) noexcept
|
|
|
|
{
|
|
|
|
return std::holds_alternative<std::reference_wrapper<T>>(ctx)
|
|
|
|
? &std::get<std::reference_wrapper<T>>(ctx).get()
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // BITCOIN_CONTEXT_VARIANT_H
|