From 898d6c7f2d0511945cc6e9099f2571f3bacf3f2e Mon Sep 17 00:00:00 2001 From: sowle Date: Sat, 25 Apr 2020 17:17:47 +0300 Subject: [PATCH 1/3] typo fixed --- .../currency_format_utils_abstract.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/currency_core/currency_format_utils_abstract.h b/src/currency_core/currency_format_utils_abstract.h index 142740ad..212e133e 100644 --- a/src/currency_core/currency_format_utils_abstract.h +++ b/src/currency_core/currency_format_utils_abstract.h @@ -68,12 +68,12 @@ namespace currency return t_unserializable_object_from_blob(b, b_blob); } //--------------------------------------------------------------- - template + template bool have_type_in_variant_container(const variant_t_container& av) { for (auto& ai : av) { - if (ai.type() == typeid(specic_type_t)) + if (ai.type() == typeid(specific_type_t)) { return true; } @@ -81,26 +81,26 @@ namespace currency return false; } //--------------------------------------------------------------- - template + template size_t count_type_in_variant_container(const variant_t_container& av) { size_t result = 0; for (auto& ai : av) { - if (ai.type() == typeid(specic_type_t)) + if (ai.type() == typeid(specific_type_t)) ++result; } return result; } //--------------------------------------------------------------- - template - bool get_type_in_variant_container(const variant_t_container& av, specic_type_t& a) + template + bool get_type_in_variant_container(const variant_t_container& av, specific_type_t& a) { for (auto& ai : av) { - if (ai.type() == typeid(specic_type_t)) + if (ai.type() == typeid(specific_type_t)) { - a = boost::get(ai); + a = boost::get(ai); return true; } } From 3883c598e5560a9b1a2fb4cf762c698b22d22e18 Mon Sep 17 00:00:00 2001 From: sowle Date: Sat, 25 Apr 2020 17:22:34 +0300 Subject: [PATCH 2/3] handle_2_alternative_types_in_variant_container --- .../currency_format_utils_abstract.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/currency_core/currency_format_utils_abstract.h b/src/currency_core/currency_format_utils_abstract.h index 212e133e..d6a48212 100644 --- a/src/currency_core/currency_format_utils_abstract.h +++ b/src/currency_core/currency_format_utils_abstract.h @@ -107,6 +107,28 @@ namespace currency return false; } //--------------------------------------------------------------- + template + bool handle_2_alternative_types_in_variant_container(const container_t& container, callback_t& cb) + { + bool found = false; + for (auto& item : container) + { + if (item.type() == typeid(A)) + { + found = true; + if (!cb(boost::get(item))) + break; + } + else if (item.type() == typeid(B)) + { + found = true; + if (!cb(boost::get(item))) + break; + } + } + return found; + } + //--------------------------------------------------------------- template bool check_allowed_types_in_variant_container(const variant_container_t& container, const std::unordered_set& allowed_types, bool elements_must_be_unique = true) { From 00304fbb7d903277ca1e604c22f530598cb9c943 Mon Sep 17 00:00:00 2001 From: sowle Date: Sat, 25 Apr 2020 17:23:05 +0300 Subject: [PATCH 3/3] wallet2::get_top_block_height --- src/wallet/wallet2.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index aa866008..4e3daada 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -633,6 +633,8 @@ namespace tools bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id); uint64_t get_blockchain_current_height() const { return m_blockchain.size(); } + + uint64_t get_top_block_height() const { return m_blockchain.empty() ? 0 : m_blockchain.size() - 1; } template inline void serialize(t_archive &a, const unsigned int ver) @@ -751,7 +753,10 @@ namespace tools static uint64_t get_max_unlock_time_from_receive_indices(const currency::transaction& tx, const money_transfer2_details& td); bool get_utxo_distribution(std::map& distribution); uint64_t get_sync_progress(); + + private: + void add_transfers_to_expiration_list(const std::vector& selected_transfers, uint64_t expiration, uint64_t change_amount, const crypto::hash& related_tx_id); void remove_transfer_from_expiration_list(uint64_t transfer_index); void load_keys(const std::string& keys_file_name, const std::string& password);