This commit is contained in:
stoffu 2018-02-16 20:04:04 +09:00
parent cc9a0bee04
commit af773211cb
No known key found for this signature in database
GPG key ID: 41DAB8343A9EC012
58 changed files with 566 additions and 357 deletions

View file

@ -268,30 +268,44 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
}
cryptonote::address_parse_info info;
bool testnet = false;
if(!cryptonote::get_account_address_from_str(info, false, args.front()))
cryptonote::network_type nettype = cryptonote::MAINNET;
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, args.front()))
{
if(!cryptonote::get_account_address_from_str(info, true, args.front()))
if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, args.front()))
{
bool dnssec_valid;
std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
[](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];});
if(!cryptonote::get_account_address_from_str(info, false, address_str))
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, args.front()))
{
if(!cryptonote::get_account_address_from_str(info, true, address_str))
bool dnssec_valid;
std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
[](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];});
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, address_str))
{
std::cout << "target account address has wrong format" << std::endl;
return true;
}
else
{
testnet = true;
if(!cryptonote::get_account_address_from_str(info, cryptonote::TESTNET, address_str))
{
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, address_str))
{
std::cout << "target account address has wrong format" << std::endl;
return true;
}
else
{
nettype = cryptonote::STAGENET;
}
}
else
{
nettype = cryptonote::TESTNET;
}
}
}
else
{
nettype = cryptonote::STAGENET;
}
}
else
{
testnet = true;
nettype = cryptonote::TESTNET;
}
}
if (info.is_subaddress)
@ -299,8 +313,8 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
tools::fail_msg_writer() << "subaddress for mining reward is not yet supported!" << std::endl;
return true;
}
if(testnet)
std::cout << "Mining to a testnet address, make sure this is intentional!" << std::endl;
if(nettype != cryptonote::MAINNET)
std::cout << "Mining to a " << (nettype == cryptonote::TESTNET ? "testnet" : "stagenet") << "address, make sure this is intentional!" << std::endl;
uint64_t threads_count = 1;
bool do_background_mining = false;
bool ignore_battery = false;
@ -325,7 +339,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
threads_count = (ok && 0 < threads_count) ? threads_count : 1;
}
m_executor.start_mining(info.address, threads_count, testnet, do_background_mining, ignore_battery);
m_executor.start_mining(info.address, threads_count, nettype, do_background_mining, ignore_battery);
return true;
}