wallet2: skip reorgs exceeding max-reorg-depth wallet setting

This commit is contained in:
xiphon 2020-10-12 21:13:58 +00:00
parent d27d4526fe
commit ec14e4b8cd
5 changed files with 56 additions and 0 deletions

View file

@ -2705,6 +2705,24 @@ bool simple_wallet::set_unit(const std::vector<std::string> &args/* = std::vecto
return true;
}
bool simple_wallet::set_max_reorg_depth(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
uint64_t depth;
if (!epee::string_tools::get_xtype_from_string(depth, args[1]))
{
fail_msg_writer() << tr("invalid value");
return true;
}
const auto pwd_container = get_and_verify_password();
if (pwd_container)
{
m_wallet->max_reorg_depth(depth);
m_wallet->rewrite(m_wallet_file, pwd_container->password());
}
return true;
}
bool simple_wallet::set_min_output_count(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
uint32_t count;
@ -3783,6 +3801,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
success_msg_writer() << "priority = " << priority<< " (" << priority_string << ")";
success_msg_writer() << "ask-password = " << m_wallet->ask_password() << " (" << ask_password_string << ")";
success_msg_writer() << "unit = " << cryptonote::get_unit(cryptonote::get_default_decimal_point());
success_msg_writer() << "max-reorg-depth = " << m_wallet->max_reorg_depth();
success_msg_writer() << "min-outputs-count = " << m_wallet->get_min_output_count();
success_msg_writer() << "min-outputs-value = " << cryptonote::print_money(m_wallet->get_min_output_value());
success_msg_writer() << "merge-destinations = " << m_wallet->merge_destinations();
@ -3853,6 +3872,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
CHECK_SIMPLE_VARIABLE("priority", set_default_priority, tr("0, 1, 2, 3, or 4, or one of ") << join_priority_strings(", "));
CHECK_SIMPLE_VARIABLE("ask-password", set_ask_password, tr("0|1|2 (or never|action|decrypt)"));
CHECK_SIMPLE_VARIABLE("unit", set_unit, tr("monero, millinero, micronero, nanonero, piconero"));
CHECK_SIMPLE_VARIABLE("max-reorg-depth", set_max_reorg_depth, tr("unsigned integer"));
CHECK_SIMPLE_VARIABLE("min-outputs-count", set_min_output_count, tr("unsigned integer"));
CHECK_SIMPLE_VARIABLE("min-outputs-value", set_min_output_value, tr("amount"));
CHECK_SIMPLE_VARIABLE("merge-destinations", set_merge_destinations, tr("0 or 1"));