From 3755f0da18f0e4968dfb7417fe55be5dad67dcbd Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 31 Aug 2020 15:40:37 +0300 Subject: [PATCH] wallet: --disable-wallet-free-space-check added for simplewallet and Zano --- src/common/command_line.cpp | 1 + src/common/command_line.h | 1 + src/simplewallet/simplewallet.cpp | 8 +++++++- src/simplewallet/simplewallet.h | 1 + src/wallet/wallet2.cpp | 15 ++++++++++++++- src/wallet/wallet2.h | 2 ++ src/wallet/wallets_manager.cpp | 3 ++- src/wallet/wallets_manager.h | 1 + 8 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index 92a59b61..a64970f1 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -31,6 +31,7 @@ namespace command_line const arg_descriptor arg_disable_stop_if_time_out_of_sync = { "disable-stop-if-time-out-of-sync", "Do not stop the daemon if serious time synchronization problem is detected", false, true }; const arg_descriptor arg_disable_stop_on_low_free_space = { "disable-stop-on-low-free-space", "Do not stop the daemon if free space at data dir is critically low", false, true }; + const arg_descriptor arg_disable_wallet_free_space_check = { "disable-wallet-free-space-check", "Disable checking for free space in wallet", false, true }; const arg_descriptor arg_enable_offers_service = { "enable-offers-service", "Enables marketplace feature", false, false}; const arg_descriptor arg_db_engine = { "db-engine", "Specify database engine for storage. May be \"lmdb\"(default) or \"mdbx\"", ARG_DB_ENGINE_LMDB, false }; diff --git a/src/common/command_line.h b/src/common/command_line.h index f19a04ae..4ad99a0d 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -210,6 +210,7 @@ namespace command_line extern const arg_descriptor arg_disable_upnp; extern const arg_descriptor arg_disable_stop_if_time_out_of_sync; extern const arg_descriptor arg_disable_stop_on_low_free_space; + extern const arg_descriptor arg_disable_wallet_free_space_check; extern const arg_descriptor arg_enable_offers_service; extern const arg_descriptor arg_db_engine; extern const arg_descriptor arg_no_predownload; diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index c37fef0a..48cba3af 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -183,7 +183,8 @@ simple_wallet::simple_wallet() m_do_not_set_date(false), m_do_pos_mining(false), m_refresh_progress_reporter(*this), - m_offline_mode(false) + m_offline_mode(false), + m_free_space_check_enabled(true) { m_cmd_binder.set_handler("start_mining", boost::bind(&simple_wallet::start_mining, this, _1), "start_mining - Start mining in daemon"); m_cmd_binder.set_handler("stop_mining", boost::bind(&simple_wallet::stop_mining, this, _1), "Stop mining in daemon"); @@ -369,6 +370,7 @@ void simple_wallet::handle_command_line(const boost::program_options::variables_ m_do_not_set_date = command_line::get_arg(vm, arg_dont_set_date); m_do_pos_mining = command_line::get_arg(vm, arg_do_pos_mining); m_restore_wallet = command_line::get_arg(vm, arg_restore_wallet); + m_free_space_check_enabled = !command_line::get_arg(vm, command_line::arg_disable_wallet_free_space_check); } //---------------------------------------------------------------------------------------------------- bool simple_wallet::try_connect_to_daemon() @@ -390,6 +392,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas m_wallet.reset(new tools::wallet2()); m_wallet->callback(this->shared_from_this()); m_wallet->set_do_rise_transfer(false); + m_wallet->set_free_space_check_enabled(m_free_space_check_enabled); try { m_wallet->generate(epee::string_encoding::utf8_to_wstring(m_wallet_file), password, create_auditable_wallet); @@ -429,6 +432,7 @@ bool simple_wallet::restore_wallet(const std::string& wallet_file, const std::st m_wallet.reset(new tools::wallet2()); m_wallet->callback(this->shared_from_this()); m_wallet->set_do_rise_transfer(true); + m_wallet->set_free_space_check_enabled(m_free_space_check_enabled); try { if (tracking_wallet) @@ -474,6 +478,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa m_wallet_file = wallet_file; m_wallet.reset(new tools::wallet2()); m_wallet->callback(shared_from_this()); + m_wallet->set_free_space_check_enabled(m_free_space_check_enabled); while (true) { @@ -1768,6 +1773,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_params, arg_offline_mode); command_line::add_arg(desc_params, command_line::arg_log_file); command_line::add_arg(desc_params, command_line::arg_log_level); + command_line::add_arg(desc_params, command_line::arg_disable_wallet_free_space_check); tools::wallet_rpc_server::init_options(desc_params); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 8fc44fc9..6f60b0aa 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -166,6 +166,7 @@ namespace currency bool m_print_brain_wallet; bool m_do_pos_mining; bool m_offline_mode; + bool m_free_space_check_enabled; std::string m_restore_wallet; epee::console_handlers_binder m_cmd_binder; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b1eae98f..e7391765 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -52,7 +52,8 @@ namespace tools m_minimum_height(WALLET_MINIMUM_HEIGHT_UNSET_CONST), m_pos_mint_packing_size(WALLET_DEFAULT_POS_MINT_PACKING_SIZE), m_current_wallet_file_size(0), - m_use_deffered_global_outputs(false) + m_use_deffered_global_outputs(false), + m_do_free_space_check(true) { m_core_runtime_config = currency::get_default_core_runtime_config(); } @@ -2514,6 +2515,15 @@ void wallet2::set_use_deffered_global_outputs(bool use) m_use_deffered_global_outputs = use; } //---------------------------------------------------------------------------------------------------- +void wallet2::set_free_space_check_enabled(bool value) +{ + if (value != m_do_free_space_check) + { + WLT_LOG_L0("free space check " << (value ? "enabled" : "disabled")); + } + m_do_free_space_check = value; +} +//---------------------------------------------------------------------------------------------------- void wallet2::store_watch_only(const std::wstring& path_to_save, const std::string& password) const { WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(path_to_save != m_wallet_file, "trying to save watch-only wallet to the same wallet file!"); @@ -2566,6 +2576,9 @@ void wallet2::check_for_free_space_and_throw_if_it_lacks(const std::wstring& wal { namespace fs = boost::filesystem; + if (!m_do_free_space_check) + return; + try { fs::path wallet_file_path(wallet_filename); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index fedc856e..4130af47 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -802,6 +802,7 @@ namespace tools uint64_t get_sync_progress(); uint64_t get_wallet_file_size()const; void set_use_deffered_global_outputs(bool use); + void set_free_space_check_enabled(bool value); private: @@ -980,6 +981,7 @@ private: mutable uint64_t m_current_wallet_file_size; bool m_use_deffered_global_outputs; + bool m_do_free_space_check; //this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions friend class test_generator; diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index e65cf6dd..828c88a7 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -63,7 +63,8 @@ wallets_manager::wallets_manager():m_pview(&m_view_stub), m_is_pos_allowed(false), m_qt_logs_enbaled(false), m_dont_save_wallet_at_stop(false), - m_use_deffered_global_outputs(false) + m_use_deffered_global_outputs(false), + m_free_space_check_enabled(true) { #ifndef MOBILE_WALLET_BUILD m_offers_service.set_disabled(true); diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index ccd054e6..3edfd7d8 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -213,6 +213,7 @@ private: bool m_remote_node_mode; bool m_qt_logs_enbaled; + bool m_free_space_check_enabled; std::string m_qt_dev_tools; std::atomic m_is_pos_allowed;