diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-01-15 12:48:25 +0000 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2018-01-28 10:52:16 +0900 |
commit | 2f5a9b6bb387f50d0ad7914d323cde33f704434e (patch) | |
tree | 1f47e8cc17b2546cf697965aa5dade97085b39f0 /src/wallet | |
parent | Merge pull request #3116 (diff) | |
download | monero-2f5a9b6bb387f50d0ad7914d323cde33f704434e.tar.xz |
wallet2: split estimate_backlog to allow for raw fee levels
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet2.cpp | 35 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 1 |
2 files changed, 27 insertions, 9 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 016b19042..589259ec8 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -9473,13 +9473,12 @@ bool wallet2::is_synced() const return get_blockchain_current_height() >= height; } //---------------------------------------------------------------------------------------------------- -std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector<uint64_t> &fees) +std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels) { - THROW_WALLET_EXCEPTION_IF(min_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); - THROW_WALLET_EXCEPTION_IF(max_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); - for (uint64_t fee: fees) + for (const auto &fee_level: fee_levels) { - THROW_WALLET_EXCEPTION_IF(fee == 0, error::wallet_internal_error, "Invalid 0 fee"); + THROW_WALLET_EXCEPTION_IF(fee_level.first == 0.0, error::wallet_internal_error, "Invalid 0 fee"); + THROW_WALLET_EXCEPTION_IF(fee_level.second == 0.0, error::wallet_internal_error, "Invalid 0 fee"); } // get txpool backlog @@ -9509,9 +9508,10 @@ std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t mi uint64_t full_reward_zone = resp_t.result.block_size_limit / 2; std::vector<std::pair<uint64_t, uint64_t>> blocks; - for (uint64_t fee: fees) + for (const auto &fee_level: fee_levels) { - double our_fee_byte_min = fee / (double)min_blob_size, our_fee_byte_max = fee / (double)max_blob_size; + const double our_fee_byte_min = fee_level.first; + const double our_fee_byte_max = fee_level.second; uint64_t priority_size_min = 0, priority_size_max = 0; for (const auto &i: res.result.backlog) { @@ -9529,14 +9529,31 @@ std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t mi uint64_t nblocks_min = priority_size_min / full_reward_zone; uint64_t nblocks_max = priority_size_max / full_reward_zone; - MDEBUG("estimate_backlog: priority_size " << priority_size_min << " - " << priority_size_max << " for " << fee - << " (" << our_fee_byte_min << " - " << our_fee_byte_max << " piconero byte fee), " + MDEBUG("estimate_backlog: priority_size " << priority_size_min << " - " << priority_size_max << " for " + << our_fee_byte_min << " - " << our_fee_byte_max << " piconero byte fee, " << nblocks_min << " - " << nblocks_max << " blocks at block size " << full_reward_zone); blocks.push_back(std::make_pair(nblocks_min, nblocks_max)); } return blocks; } //---------------------------------------------------------------------------------------------------- +std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector<uint64_t> &fees) +{ + THROW_WALLET_EXCEPTION_IF(min_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); + THROW_WALLET_EXCEPTION_IF(max_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); + for (uint64_t fee: fees) + { + THROW_WALLET_EXCEPTION_IF(fee == 0, error::wallet_internal_error, "Invalid 0 fee"); + } + std::vector<std::pair<double, double>> fee_levels; + for (uint64_t fee: fees) + { + double our_fee_byte_min = fee / (double)min_blob_size, our_fee_byte_max = fee / (double)max_blob_size; + fee_levels.emplace_back(our_fee_byte_min, our_fee_byte_max); + } + return estimate_backlog(fee_levels); +} +//---------------------------------------------------------------------------------------------------- void wallet2::generate_genesis(cryptonote::block& b) const { if (m_testnet) { diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index e68531cbf..57ede86c2 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -956,6 +956,7 @@ namespace tools bool is_synced() const; + std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels); std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector<uint64_t> &fees); uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1) const; |