From 37bd4009c1850017bd7a53345101217ebf654509 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 11 Jul 2024 22:20:12 +0700 Subject: [PATCH] refactor: use monostate instead std::optional in CoreContext --- src/context.h | 4 ++-- src/node/interfaces.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/context.h b/src/context.h index 11b25b35b7..70fc00cd95 100644 --- a/src/context.h +++ b/src/context.h @@ -5,8 +5,8 @@ #ifndef BITCOIN_CONTEXT_H #define BITCOIN_CONTEXT_H +#include #include -#include class ChainstateManager; class CTxMemPool; @@ -15,7 +15,7 @@ struct LLMQContext; struct NodeContext; struct WalletContext; -using CoreContext = std::variant, std::reference_wrapper, std::reference_wrapper, diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index be4a3de421..f74983b871 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -67,6 +67,7 @@ #include #include #include +#include using interfaces::BlockTip; using interfaces::Chain; @@ -584,11 +585,11 @@ public: if (context) { m_context_ref = *context; } else { - m_context_ref = std::nullopt; + m_context_ref = std::monostate{}; } } NodeContext* m_context{nullptr}; - CoreContext m_context_ref{std::nullopt}; + CoreContext m_context_ref; }; bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock& lock, const CChain& active)