diff --git a/src/primitives/transaction_identifier.h b/src/primitives/transaction_identifier.h index a1109591277..9479d2be519 100644 --- a/src/primitives/transaction_identifier.h +++ b/src/primitives/transaction_identifier.h @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -28,22 +27,12 @@ class transaction_identifier // Note: Use FromUint256 externally instead. transaction_identifier(const uint256& wrapped) : m_wrapped{wrapped} {} - constexpr int Compare(const transaction_identifier& other) const { return m_wrapped.Compare(other.m_wrapped); } - template - constexpr int Compare(const Other& other) const - { - static_assert(ALWAYS_FALSE, "Forbidden comparison type"); - return 0; - } - public: transaction_identifier() : m_wrapped{} {} consteval explicit transaction_identifier(std::string_view hex_str) : m_wrapped{uint256{hex_str}} {} - template - bool operator==(const Other& other) const { return Compare(other) == 0; } - template - std::strong_ordering operator<=>(const Other& other) const { return Compare(other) <=> 0; } + constexpr bool operator==(const transaction_identifier&) const = default; + constexpr auto operator<=>(const transaction_identifier&) const = default; const uint256& ToUint256() const LIFETIMEBOUND { return m_wrapped; } static transaction_identifier FromUint256(const uint256& id) { return {id}; } diff --git a/src/uint256.h b/src/uint256.h index 00db02d058a..d7229169fd5 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -65,14 +65,7 @@ public: * @note Does NOT match the ordering on the corresponding \ref * base_uint::CompareTo, which starts comparing from the end. */ - constexpr int Compare(const base_blob& other) const { - auto cmp = m_data <=> other.m_data; - if (cmp < 0) return -1; - if (cmp > 0) return 1; - return 0; - } - - friend constexpr bool operator<(const base_blob& a, const base_blob& b) { return a.Compare(b) < 0; } + constexpr std::strong_ordering operator<=>(const base_blob& other) const = default; /** @name Hex representation *