diff --git a/src/common/make_hashable.h b/src/common/make_hashable.h index af18f478..c22bfa45 100644 --- a/src/common/make_hashable.h +++ b/src/common/make_hashable.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Zano Project +// Copyright (c) 2014-2020 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Cryptonote developers // Copyright (c) 2012-2013 The Boolberry developers @@ -37,3 +37,21 @@ namespace std { \ } \ }; \ } + +namespace std +{ + + // this allows using std::pair<> as a key in unordered std containers + template + struct hash> + { + size_t operator()(const pair& p) const + { + auto hash1 = hash{}(p.first); + auto hash2 = hash{}(p.second); + return hash1 ^ hash2; + } + }; + +} // namespace std + diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index f228ad78..117b1771 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -593,14 +593,28 @@ void simple_wallet::on_new_block(uint64_t height, const currency::block& block) m_refresh_progress_reporter.update(height, false); } //---------------------------------------------------------------------------------------------------- +std::string print_money_trailing_zeros_replaced_with_spaces(uint64_t amount) +{ + std::string s = print_money(amount); + size_t p = s.find_last_not_of('0'); + if (p != std::string::npos) + { + if (s[p] == '.') + ++p; + size_t l = s.length() - p - 1; + return s.replace(p + 1, l, l, ' '); + } + return s; +} +//---------------------------------------------------------------------------------------------------- void simple_wallet::on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) { epee::log_space::console_colors color = wti.is_income ? epee::log_space::console_color_green : epee::log_space::console_color_magenta; message_writer(color, false) << "height " << wti.height << ", tx " << wti.tx_hash << - (wti.is_income ? ", received " : ", spent ") << print_money_brief(wti.amount) << - ", balance: " << print_money_brief(balance); + " " << std::right << std::setw(18) << print_money_trailing_zeros_replaced_with_spaces(wti.amount) << (wti.is_income ? " received," : " spent, ") << + " balance: " << print_money_brief(balance); m_refresh_progress_reporter.update(wti.height, true); } //---------------------------------------------------------------------------------------------------- diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index f9b3498f..00f27450 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Zano Project +// Copyright (c) 2014-2020 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying @@ -24,6 +24,7 @@ #include "currency_core/account_boost_serialization.h" #include "currency_core/currency_format_utils.h" +#include "common/make_hashable.h" #include "wallet_public_structs_defs.h" #include "currency_core/currency_format_utils.h" #include "common/unordered_containers_boost_serialization.h" @@ -72,22 +73,6 @@ const uint64_t WALLET_MINIMUM_HEIGHT_UNSET_CONST = std::numeric_limits class test_generator; -namespace std -{ - - template - struct hash> - { - size_t operator()(const pair& p) const - { - auto hash1 = hash{}(p.first); - auto hash2 = hash{}(p.second); - return hash1 ^ hash2; - } - }; - -} // namespace std - namespace tools { #pragma pack(push, 1)