diff --git a/src/radix.h b/src/radix.h --- a/src/radix.h +++ b/src/radix.h @@ -5,7 +5,6 @@ #ifndef BITCOIN_RADIX_H #define BITCOIN_RADIX_H -#include #include #include @@ -397,24 +396,4 @@ "RadixNode alignment must be 2 or more."); }; -/** - * Facility for using an uint256 as a radix tree key. - */ -struct Uint256RadixKey { - arith_uint256 base; - - Uint256RadixKey(const uint256 &keyIn) : base(UintToArith256(keyIn)) {} - Uint256RadixKey(const base_uint<256> &keyIn) : base(keyIn) {} - - Uint256RadixKey operator>>(uint32_t shift) const { return base >> shift; } - Uint256RadixKey operator&(const Uint256RadixKey &mask) const { - return base & mask.base; - } - operator size_t() const { return size_t(base.GetLow64()); } -}; - -// The radix tree relies on sizeof to gather the bit length of the key -static_assert(sizeof(Uint256RadixKey) == 32, - "Uint256RadixKey key size should be 256 bits"); - #endif // BITCOIN_RADIX_H diff --git a/src/test/radix_tests.cpp b/src/test/radix_tests.cpp --- a/src/test/radix_tests.cpp +++ b/src/test/radix_tests.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/src/uint256radixkey.h b/src/uint256radixkey.h new file mode 100644 --- /dev/null +++ b/src/uint256radixkey.h @@ -0,0 +1,34 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_UINT256RADIXKEY_H +#define BITCOIN_UINT256RADIXKEY_H + +#include + +#include + +class uint256; + +/** + * Facility for using an uint256 as a radix tree key. + */ +struct Uint256RadixKey { + arith_uint256 base; + + Uint256RadixKey(const uint256 &keyIn) : base(UintToArith256(keyIn)) {} + Uint256RadixKey(const base_uint<256> &keyIn) : base(keyIn) {} + + Uint256RadixKey operator>>(uint32_t shift) const { return base >> shift; } + Uint256RadixKey operator&(const Uint256RadixKey &mask) const { + return base & mask.base; + } + operator size_t() const { return size_t(base.GetLow64()); } +}; + +// The radix tree relies on sizeof to gather the bit length of the key +static_assert(sizeof(Uint256RadixKey) == 32, + "Uint256RadixKey key size should be 256 bits"); + +#endif // BITCOIN_UINT256RADIXKEY_H