From df087b40c3e5f2801667cad84abf5bb8ee100927 Mon Sep 17 00:00:00 2001 From: sowle Date: Sun, 6 Aug 2023 00:00:02 +0200 Subject: [PATCH] core: copmarison operators --- src/currency_core/currency_basic.h | 7 ++++ src/currency_core/currency_format_utils.cpp | 45 ++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 7a013ba2..3ad4cf45 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -1131,6 +1131,13 @@ namespace currency bool operator ==(const currency::zarcanum_sig& a, const currency::zarcanum_sig& b); bool operator ==(const currency::ref_by_id& a, const currency::ref_by_id& b); + // TODO: REPLACE all of the following operators to "bool operator==(..) const = default" once we moved to C++20 -- sowle + bool operator ==(const currency::signed_parts& a, const currency::signed_parts& b); + bool operator ==(const currency::txin_gen& a, const currency::txin_gen& b); + bool operator ==(const currency::txin_to_key& a, const currency::txin_to_key& b); + bool operator ==(const currency::txin_multisig& a, const currency::txin_multisig& b); + bool operator ==(const currency::txin_htlc& a, const currency::txin_htlc& b); + bool operator ==(const currency::txin_zc_input& a, const currency::txin_zc_input& b); } // namespace currency POD_MAKE_HASHABLE(currency, account_public_address); diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index a714d694..fcf9a8f0 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -4242,7 +4242,50 @@ namespace currency return a.n == b.n && a.tx_id == b.tx_id; } //-------------------------------------------------------------------------------- - + bool operator ==(const currency::signed_parts& a, const currency::signed_parts& b) + { + return + a.n_extras == b.n_extras && + a.n_outs == b.n_outs; + } + bool operator ==(const currency::txin_gen& a, const currency::txin_gen& b) + { + return a.height == b.height; + } + bool operator ==(const currency::txin_to_key& a, const currency::txin_to_key& b) + { + return + a.amount == b.amount && + a.etc_details == b.etc_details && + a.key_offsets == b.key_offsets && + a.k_image == b.k_image; + } + bool operator ==(const currency::txin_multisig& a, const currency::txin_multisig& b) + { + return + a.amount == b.amount && + a.etc_details == b.etc_details && + a.multisig_out_id == b.multisig_out_id && + a.sigs_count == b.sigs_count; + } + bool operator ==(const currency::txin_htlc& a, const currency::txin_htlc& b) + { + return + a.amount == b.amount && + a.etc_details == b.etc_details && + a.hltc_origin == b.hltc_origin && + a.key_offsets == b.key_offsets && + a.k_image == b.k_image; + } + bool operator ==(const currency::txin_zc_input& a, const currency::txin_zc_input& b) + { + return + a.etc_details == b.etc_details && + a.key_offsets == b.key_offsets && + a.k_image == b.k_image; + } + //-------------------------------------------------------------------------------- + boost::multiprecision::uint1024_t get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point, const wide_difficulty_type& difficulty_pow_at_split_point,