mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 13:23:29 +01:00
wallet: make the refresh optimizations selectable via command line
Take the opportunity to add a no-coinbase case too, for even faster sync when an address is known to never have mined to.
This commit is contained in:
parent
d2c031332e
commit
9b945f5211
@ -93,6 +93,7 @@ namespace
|
||||
const command_line::arg_descriptor<bool> arg_testnet = {"testnet", sw::tr("Used to deploy test nets. The daemon must be launched with --testnet flag"), false};
|
||||
const command_line::arg_descriptor<bool> arg_restricted = {"restricted-rpc", sw::tr("Restricts RPC to view only commands"), false};
|
||||
const command_line::arg_descriptor<bool> arg_trusted_daemon = {"trusted-daemon", sw::tr("Enable commands which rely on a trusted daemon"), false};
|
||||
const command_line::arg_descriptor<std::string> arg_refresh_type = {"refresh-type", sw::tr("Control the wallet refresh speedup/assumptions balance: full (slowest, no assumptions), optimize-coinbase (fast, assumes the whole coinbase is paid to a single address), no-coinbase (fastest, assumes we receive no coinbase transaction)"), "optimize-coinbase"};
|
||||
|
||||
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
|
||||
|
||||
@ -631,7 +632,8 @@ void simple_wallet::print_seed(std::string seed)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::init(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
handle_command_line(vm);
|
||||
if (!handle_command_line(vm))
|
||||
return false;
|
||||
|
||||
if (!m_daemon_address.empty() && !m_daemon_host.empty() && 0 != m_daemon_port)
|
||||
{
|
||||
@ -769,7 +771,32 @@ bool simple_wallet::deinit()
|
||||
return close_wallet();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void simple_wallet::handle_command_line(const boost::program_options::variables_map& vm)
|
||||
static bool parse_refresh_type(const std::string &s, tools::wallet2::RefreshType &refresh_type)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
tools::wallet2::RefreshType refresh_type;
|
||||
} names[] =
|
||||
{
|
||||
{ "full", tools::wallet2::RefreshFull },
|
||||
{ "optimize-coinbase", tools::wallet2::RefreshOptimizeCoinbase },
|
||||
{ "optimized-coinbase", tools::wallet2::RefreshOptimizeCoinbase },
|
||||
{ "no-coinbase", tools::wallet2::RefreshNoCoinbase },
|
||||
};
|
||||
for (size_t n = 0; n < sizeof(names) / sizeof(names[0]); ++n)
|
||||
{
|
||||
if (s == names[n].name)
|
||||
{
|
||||
refresh_type = names[n].refresh_type;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
fail_msg_writer() << tr("Failed to parse refresh type");
|
||||
return false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::handle_command_line(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
m_wallet_file = command_line::get_arg(vm, arg_wallet_file);
|
||||
m_generate_new = command_line::get_arg(vm, arg_generate_new_wallet);
|
||||
@ -781,6 +808,12 @@ void simple_wallet::handle_command_line(const boost::program_options::variables_
|
||||
m_restore_deterministic_wallet = command_line::get_arg(vm, arg_restore_deterministic_wallet);
|
||||
m_non_deterministic = command_line::get_arg(vm, arg_non_deterministic);
|
||||
m_trusted_daemon = command_line::get_arg(vm, arg_trusted_daemon);
|
||||
std::string refresh_type = command_line::get_arg(vm, arg_refresh_type);
|
||||
|
||||
if (!parse_refresh_type(refresh_type, m_refresh_type))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::try_connect_to_daemon()
|
||||
@ -863,6 +896,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
||||
m_wallet.reset(new tools::wallet2(testnet));
|
||||
m_wallet->callback(this);
|
||||
m_wallet->set_seed_language(mnemonic_language);
|
||||
m_wallet->set_refresh_type(m_refresh_type);
|
||||
|
||||
crypto::secret_key recovery_val;
|
||||
try
|
||||
@ -911,6 +945,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string
|
||||
|
||||
m_wallet.reset(new tools::wallet2(testnet));
|
||||
m_wallet->callback(this);
|
||||
m_wallet->set_refresh_type(m_refresh_type);
|
||||
|
||||
try
|
||||
{
|
||||
@ -941,6 +976,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(testnet));
|
||||
m_wallet->callback(this);
|
||||
m_wallet->set_refresh_type(m_refresh_type);
|
||||
|
||||
try
|
||||
{
|
||||
@ -2229,6 +2265,7 @@ int main(int argc, char* argv[])
|
||||
command_line::add_arg(desc_params, arg_testnet);
|
||||
command_line::add_arg(desc_params, arg_restricted);
|
||||
command_line::add_arg(desc_params, arg_trusted_daemon);
|
||||
command_line::add_arg(desc_params, arg_refresh_type);
|
||||
tools::wallet_rpc_server::init_options(desc_params);
|
||||
|
||||
po::positional_options_description positional_options;
|
||||
|
@ -73,7 +73,7 @@ namespace cryptonote
|
||||
bool process_command(const std::vector<std::string> &args);
|
||||
std::string get_commands_str();
|
||||
private:
|
||||
void handle_command_line(const boost::program_options::variables_map& vm);
|
||||
bool handle_command_line(const boost::program_options::variables_map& vm);
|
||||
|
||||
bool run_console_handler();
|
||||
|
||||
@ -222,6 +222,8 @@ namespace cryptonote
|
||||
std::string m_daemon_host;
|
||||
int m_daemon_port;
|
||||
|
||||
tools::wallet2::RefreshType m_refresh_type;
|
||||
|
||||
epee::console_handlers_binder m_cmd_binder;
|
||||
|
||||
std::unique_ptr<tools::wallet2> m_wallet;
|
||||
|
@ -204,7 +204,11 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_
|
||||
tx_pub_key = pub_key_field.pub_key;
|
||||
bool r = true;
|
||||
int threads;
|
||||
if (miner_tx)
|
||||
if (miner_tx && m_refresh_type == RefreshNoCoinbase)
|
||||
{
|
||||
// assume coinbase isn't for us
|
||||
}
|
||||
else if (miner_tx && m_refresh_type == RefreshOptimizeCoinbase)
|
||||
{
|
||||
for (size_t i = 0; i < tx.vout.size(); ++i)
|
||||
{
|
||||
|
@ -79,9 +79,18 @@ namespace tools
|
||||
|
||||
class wallet2
|
||||
{
|
||||
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false), m_always_confirm_transfers (false), m_store_tx_info(true), m_default_mixin(0) {}
|
||||
public:
|
||||
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_restricted(restricted), is_old_file_format(false), m_store_tx_info(true), m_default_mixin(0) {}
|
||||
enum RefreshType {
|
||||
RefreshFull,
|
||||
RefreshOptimizeCoinbase,
|
||||
RefreshNoCoinbase,
|
||||
};
|
||||
|
||||
private:
|
||||
wallet2(const wallet2&) : m_run(true), m_callback(0), m_testnet(false), m_always_confirm_transfers (false), m_store_tx_info(true), m_default_mixin(0), m_refresh_type(RefreshOptimizeCoinbase) {}
|
||||
|
||||
public:
|
||||
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_restricted(restricted), is_old_file_format(false), m_store_tx_info(true), m_default_mixin(0), m_refresh_type(RefreshOptimizeCoinbase) {}
|
||||
struct transfer_details
|
||||
{
|
||||
uint64_t m_block_height;
|
||||
@ -234,6 +243,9 @@ namespace tools
|
||||
void refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& received_money);
|
||||
bool refresh(uint64_t & blocks_fetched, bool& received_money, bool& ok);
|
||||
|
||||
void set_refresh_type(RefreshType refresh_type) { m_refresh_type = refresh_type; }
|
||||
RefreshType get_refresh_type(RefreshType refresh_type) const { return m_refresh_type; }
|
||||
|
||||
bool testnet() const { return m_testnet; }
|
||||
bool restricted() const { return m_restricted; }
|
||||
bool watch_only() const { return m_watch_only; }
|
||||
@ -384,6 +396,7 @@ namespace tools
|
||||
bool m_always_confirm_transfers;
|
||||
bool m_store_tx_info; /*!< request txkey to be returned in RPC, and store in the wallet cache file */
|
||||
uint32_t m_default_mixin;
|
||||
RefreshType m_refresh_type;
|
||||
};
|
||||
}
|
||||
BOOST_CLASS_VERSION(tools::wallet2, 10)
|
||||
|
Loading…
Reference in New Issue
Block a user