mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
refactor: use monostate instead std::optional in CoreContext
This commit is contained in:
parent
1394c41c8d
commit
37bd4009c1
@ -5,8 +5,8 @@
|
|||||||
#ifndef BITCOIN_CONTEXT_H
|
#ifndef BITCOIN_CONTEXT_H
|
||||||
#define BITCOIN_CONTEXT_H
|
#define BITCOIN_CONTEXT_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
class ChainstateManager;
|
class ChainstateManager;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
@ -15,7 +15,7 @@ struct LLMQContext;
|
|||||||
struct NodeContext;
|
struct NodeContext;
|
||||||
struct WalletContext;
|
struct WalletContext;
|
||||||
|
|
||||||
using CoreContext = std::variant<std::nullopt_t,
|
using CoreContext = std::variant<std::monostate,
|
||||||
std::reference_wrapper<NodeContext>,
|
std::reference_wrapper<NodeContext>,
|
||||||
std::reference_wrapper<WalletContext>,
|
std::reference_wrapper<WalletContext>,
|
||||||
std::reference_wrapper<CTxMemPool>,
|
std::reference_wrapper<CTxMemPool>,
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
using interfaces::BlockTip;
|
using interfaces::BlockTip;
|
||||||
using interfaces::Chain;
|
using interfaces::Chain;
|
||||||
@ -584,11 +585,11 @@ public:
|
|||||||
if (context) {
|
if (context) {
|
||||||
m_context_ref = *context;
|
m_context_ref = *context;
|
||||||
} else {
|
} else {
|
||||||
m_context_ref = std::nullopt;
|
m_context_ref = std::monostate{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NodeContext* m_context{nullptr};
|
NodeContext* m_context{nullptr};
|
||||||
CoreContext m_context_ref{std::nullopt};
|
CoreContext m_context_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active)
|
bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<RecursiveMutex>& lock, const CChain& active)
|
||||||
|
Loading…
Reference in New Issue
Block a user