From 2f5a9b6bb387f50d0ad7914d323cde33f704434e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 15 Jan 2018 12:48:25 +0000 Subject: wallet2: split estimate_backlog to allow for raw fee levels --- src/wallet/wallet2.cpp | 35 ++++++++++++++++++++++++++--------- src/wallet/wallet2.h | 1 + 2 files changed, 27 insertions(+), 9 deletions(-) (limited to 'src/wallet') 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> wallet2::estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector &fees) +std::vector> wallet2::estimate_backlog(const std::vector> &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> wallet2::estimate_backlog(uint64_t mi uint64_t full_reward_zone = resp_t.result.block_size_limit / 2; std::vector> 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> 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> wallet2::estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector &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> 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> estimate_backlog(const std::vector> &fee_levels); std::vector> estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector &fees); uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1) const; -- cgit v1.2.3