diff options
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/rest.cpp | 2 | ||||
-rw-r--r-- | src/rpc/node.cpp | 2 | ||||
-rw-r--r-- | src/rpc/server_util.cpp | 2 | ||||
-rw-r--r-- | src/util/any.h | 26 | ||||
-rw-r--r-- | src/util/system.h | 17 | ||||
-rw-r--r-- | src/wallet/rpc/util.cpp | 2 |
7 files changed, 31 insertions, 21 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index c952d73758..e2c7af8c58 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -279,6 +279,7 @@ BITCOIN_CORE_H = \ txorphanage.h \ txrequest.h \ undo.h \ + util/any.h \ util/asmap.h \ util/batchpriority.h \ util/bip32.h \ diff --git a/src/rest.cpp b/src/rest.cpp index dae064f89d..c9e61d70bd 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -24,8 +24,8 @@ #include <streams.h> #include <sync.h> #include <txmempool.h> +#include <util/any.h> #include <util/check.h> -#include <util/system.h> #include <validation.h> #include <version.h> diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp index ca8db0f82a..45d46d223b 100644 --- a/src/rpc/node.cpp +++ b/src/rpc/node.cpp @@ -19,9 +19,9 @@ #include <rpc/util.h> #include <scheduler.h> #include <univalue.h> +#include <util/any.h> #include <util/check.h> #include <util/syscall_sandbox.h> -#include <util/system.h> #include <stdint.h> #ifdef HAVE_MALLOC_INFO diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp index 13d007b496..1d4afb3758 100644 --- a/src/rpc/server_util.cpp +++ b/src/rpc/server_util.cpp @@ -11,7 +11,7 @@ #include <rpc/protocol.h> #include <rpc/request.h> #include <txmempool.h> -#include <util/system.h> +#include <util/any.h> #include <validation.h> #include <any> diff --git a/src/util/any.h b/src/util/any.h new file mode 100644 index 0000000000..4562c5bd8a --- /dev/null +++ b/src/util/any.h @@ -0,0 +1,26 @@ +// Copyright (c) 2023 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UTIL_ANY_H +#define BITCOIN_UTIL_ANY_H + +#include <any> + +namespace util { + +/** + * Helper function to access the contained object of a std::any instance. + * Returns a pointer to the object if passed instance has a value and the type + * matches, nullptr otherwise. + */ +template<typename T> +T* AnyPtr(const std::any& any) noexcept +{ + T* const* ptr = std::any_cast<T*>(&any); + return ptr ? *ptr : nullptr; +} + +} // namespace util + +#endif // BITCOIN_UTIL_ANY_H diff --git a/src/util/system.h b/src/util/system.h index 463713d565..719cd28f97 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -13,7 +13,6 @@ #include <compat/assumptions.h> #include <compat/compat.h> -#include <any> #include <set> #include <stdint.h> #include <string> @@ -36,20 +35,4 @@ void runCommand(const std::string& strCommand); */ int GetNumCores(); -namespace util { - -/** - * Helper function to access the contained object of a std::any instance. - * Returns a pointer to the object if passed instance has a value and the type - * matches, nullptr otherwise. - */ -template<typename T> -T* AnyPtr(const std::any& any) noexcept -{ - T* const* ptr = std::any_cast<T*>(&any); - return ptr ? *ptr : nullptr; -} - -} // namespace util - #endif // BITCOIN_UTIL_SYSTEM_H diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp index 4ff44b84b0..06ec7db1bc 100644 --- a/src/wallet/rpc/util.cpp +++ b/src/wallet/rpc/util.cpp @@ -6,7 +6,7 @@ #include <common/url.h> #include <rpc/util.h> -#include <util/system.h> +#include <util/any.h> #include <util/translation.h> #include <wallet/context.h> #include <wallet/wallet.h> |