forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontext.h
More file actions
40 lines (34 loc) · 1.33 KB
/
context.h
File metadata and controls
40 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2022-2025 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 <functional>
#include <variant>
class ArgsManager;
class ChainstateManager;
class CTxMemPool;
class CBlockPolicyEstimator;
struct LLMQContext;
namespace node {
struct NodeContext;
} // namespace node
namespace wallet {
struct WalletContext;
} // namespace wallet
using CoreContext = std::variant<std::monostate,
std::reference_wrapper<ArgsManager>,
std::reference_wrapper<node::NodeContext>,
std::reference_wrapper<wallet::WalletContext>,
std::reference_wrapper<CTxMemPool>,
std::reference_wrapper<ChainstateManager>,
std::reference_wrapper<CBlockPolicyEstimator>,
std::reference_wrapper<LLMQContext>>;
template<typename T>
T* GetContext(const CoreContext& context) noexcept
{
return std::holds_alternative<std::reference_wrapper<T>>(context)
? &std::get<std::reference_wrapper<T>>(context).get()
: nullptr;
}
#endif // BITCOIN_CONTEXT_H