diff --git a/src/currency_core/currency_format_utils_abstract.h b/src/currency_core/currency_format_utils_abstract.h index 142740ad..d6a48212 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,32 +81,54 @@ 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; } } 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) { 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);