diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 5dcb638e..63660085 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3851,10 +3851,10 @@ namespace tools } //delete from recent_history - //if (m_transfer_history.size() > WALLET_CONCISE_MODE_MAX_HISTORY_SIZE) - //{ - // m_transfer_history.erase(m_transfer_history.begin(), m_transfer_history.end() - WALLET_CONCISE_MODE_MAX_HISTORY_SIZE); - //} + if (m_truncate_history_max_entries != 0 && m_transfer_history.size() > m_truncate_history_max_entries) + { + m_transfer_history.erase(m_transfer_history.begin(), m_transfer_history.end() - m_truncate_history_max_entries); + } return true; } diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 25220784..af807321 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -51,7 +51,7 @@ #define WALLET_DEFAULT_TX_SPENDABLE_AGE CURRENCY_HF4_MANDATORY_MIN_COINAGE #define WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL 1 #define WALLET_CONCISE_MODE_MAX_REORG_BLOCKS CURRENCY_BLOCKS_PER_DAY * 7 //week -#define WALLET_CONCISE_MODE_MAX_HISTORY_SIZE 500 +#define WALLET_CONCISE_MODE_MOBILE_MAX_HISTORY_SIZE 500 const uint64_t WALLET_MINIMUM_HEIGHT_UNSET_CONST = std::numeric_limits::max(); @@ -755,6 +755,7 @@ namespace tools bool proxy_to_daemon(const std::string& uri, const std::string& body, int& response_code, std::string& response_body); void set_concise_mode(bool enabled) { m_concise_mode = enabled; } void set_concise_mode_reorg_max_reorg_blocks(uint64_t max_blocks) { m_wallet_concise_mode_max_reorg_blocks = max_blocks; } + void set_concise_mode_truncate_history(uint64_t max_entries) { m_truncate_history_max_entries = max_entries; } construct_tx_param get_default_construct_tx_param(); @@ -975,9 +976,14 @@ private: std::atomic m_concise_mode = true; //in this mode the wallet don't keep spent entries in m_transfers as well as m_recent_transfers longer then 100 entries uint64_t m_last_known_daemon_height = 0; - uint64_t m_wallet_concise_mode_max_reorg_blocks = 5;//WALLET_CONCISE_MODE_MAX_REORG_BLOCKS; + uint64_t m_wallet_concise_mode_max_reorg_blocks = WALLET_CONCISE_MODE_MAX_REORG_BLOCKS; uint64_t m_full_resync_requested_at_h = 0; - + uint64_t m_truncate_history_max_entries +#ifdef MOBILE_WALLET_BUILD + = WALLET_CONCISE_MODE_MOBILE_MAX_HISTORY_SIZE; +#else + = 0; +#endif //this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions friend class test_generator; }; // class wallet2 diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 09092b43..1e108324 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -997,6 +997,8 @@ bool test_generator::init_test_wallet(const currency::account_base& account, con w->set_genesis(genesis_hash); w->set_core_proxy(m_wallet_test_core_proxy); w->set_disable_tor_relay(true); + w->set_concise_mode(true); + w->set_concise_mode_reorg_max_reorg_blocks(TESTS_CONCISE_MODE_REORG_MAX_REORG_BLOCK); result = w; return true; diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index d8d49100..976a6222 100644 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -19,8 +19,10 @@ #define TESTS_DEFAULT_FEE ((uint64_t)TX_DEFAULT_FEE) #define MK_TEST_COINS(amount) (static_cast(amount) * TX_DEFAULT_FEE) -#define TESTS_POS_CONFIG_MIN_COINSTAKE_AGE 4 -#define TESTS_POS_CONFIG_POS_MINIMUM_HEIGH 4 +#define TESTS_POS_CONFIG_MIN_COINSTAKE_AGE 4 +#define TESTS_POS_CONFIG_POS_MINIMUM_HEIGH 4 +#define TESTS_CONCISE_MODE_REORG_MAX_REORG_BLOCK 5 + namespace concolor { diff --git a/tests/core_tests/wallet_tests_basic.h b/tests/core_tests/wallet_tests_basic.h index 6515b4a7..923376c1 100644 --- a/tests/core_tests/wallet_tests_basic.h +++ b/tests/core_tests/wallet_tests_basic.h @@ -57,6 +57,8 @@ struct wallet_test : virtual public test_chain_unit_enchanced w->set_genesis(genesis_hash); w->set_core_proxy(m_core_proxy); w->set_disable_tor_relay(true); + w->set_concise_mode(true); + w->set_concise_mode_reorg_max_reorg_blocks(TESTS_CONCISE_MODE_REORG_MAX_REORG_BLOCK); return w; }