From e35f3c2babe8b98e73f6be242fca8c8365087dff Mon Sep 17 00:00:00 2001 From: Javier Smooth Date: Tue, 11 Aug 2015 22:44:35 -0700 Subject: [PATCH] Add donation mining --- src/cryptonote_config.h | 1 + src/cryptonote_core/miner.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 263814c..43709f2 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -122,3 +122,4 @@ #define THREAD_STACK_SIZE 5 * 1024 * 1024 +#define CONFIG_DONATION_ADDRESS "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs" diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp index 500d79c..6f4cbcd 100644 --- a/src/cryptonote_core/miner.cpp +++ b/src/cryptonote_core/miner.cpp @@ -58,6 +58,7 @@ namespace cryptonote const command_line::arg_descriptor arg_extra_messages = {"extra-messages-file", "Specify file for extra messages to include into coinbase transactions", "", true}; const command_line::arg_descriptor arg_start_mining = {"start-mining", "Specify wallet address to mining for", "", true}; const command_line::arg_descriptor arg_mining_threads = {"mining-threads", "Specify mining threads count", 0, true}; + const command_line::arg_descriptor arg_donate = {"donate", "Enable background donation mining"}; } @@ -169,6 +170,7 @@ namespace cryptonote command_line::add_arg(desc, arg_extra_messages); command_line::add_arg(desc, arg_start_mining); command_line::add_arg(desc, arg_mining_threads); + command_line::add_arg(desc, arg_donate); } //----------------------------------------------------------------------------------------------------- bool miner::init(const boost::program_options::variables_map& vm) @@ -196,9 +198,17 @@ namespace cryptonote LOG_PRINT_L0("Loaded " << m_extra_messages.size() << " extra messages, current index " << m_config.current_extra_message_index); } - if(command_line::has_arg(vm, arg_start_mining)) + if(command_line::has_arg(vm, arg_start_mining) || command_line::has_arg(vm, arg_donate)) { - if(!cryptonote::get_account_address_from_str(m_mine_address, command_line::get_arg(vm, arg_start_mining))) + if(command_line::has_arg(vm, arg_donate)) + { + if (!cryptonote::get_account_address_from_str(m_mine_address, std::string(CONFIG_DONATION_ADDRESS))) + { + LOG_ERROR("Internal error: malformed donation address"); + return false; + } + } + else if(!cryptonote::get_account_address_from_str(m_mine_address, command_line::get_arg(vm, arg_start_mining))) { LOG_ERROR("Target account address " << command_line::get_arg(vm, arg_start_mining) << " has wrong format, starting daemon canceled"); return false;