34 #include <boost/utility/value_init.hpp> 35 #include <boost/interprocess/detail/atomic.hpp> 36 #include <boost/algorithm/string.hpp> 46 #include "boost/logic/tribool.hpp" 49 #include <sys/times.h> 50 #include <IOKit/IOKitLib.h> 51 #include <IOKit/ps/IOPSKeys.h> 52 #include <IOKit/ps/IOPowerSources.h> 53 #include <mach/mach_host.h> 54 #include <AvailabilityMacros.h> 55 #include <TargetConditionals.h> 56 #elif defined(__linux__) 58 #include <sys/resource.h> 59 #include <sys/times.h> 61 #elif defined(__FreeBSD__) 65 #include <machine/apm_bios.h> 67 #include <sys/resource.h> 68 #include <sys/sysctl.h> 69 #include <sys/times.h> 70 #include <sys/types.h> 74 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY 75 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "miner" 77 #define AUTODETECT_WINDOW 10 // seconds 78 #define AUTODETECT_GAIN_THRESHOLD 1.02f // 2% 96 const command_line::arg_descriptor<bool> arg_bg_mining_ignore_battery = {
"bg-mining-ignore-battery",
"if true, assumes plugged in when unable to query system power status",
false,
true};
97 const command_line::arg_descriptor<uint64_t> arg_bg_mining_min_idle_interval_seconds = {
"bg-mining-min-idle-interval",
"Specify min lookback interval in seconds for determining idle state", miner::BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS,
true};
98 const command_line::arg_descriptor<uint16_t> arg_bg_mining_idle_threshold_percentage = {
"bg-mining-idle-threshold",
"Specify minimum avg idle percentage over lookback interval", miner::BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE,
true};
99 const command_line::arg_descriptor<uint16_t> arg_bg_mining_miner_target_percentage = {
"bg-mining-miner-target",
"Specify maximum percentage cpu use by miner(s)", miner::BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE,
true};
104 m_template(
boost::value_initialized<
block>()),
108 m_phandler(phandler),
114 m_last_hr_merge_time(0),
117 m_do_print_hashrate(
false),
119 m_current_hash_rate(0),
120 m_is_background_mining_enabled(
false),
121 m_min_idle_seconds(BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS),
122 m_idle_threshold(BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE),
123 m_mining_target(BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE),
124 m_miner_extra_sleep(BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS),
142 m_block_reward = block_reward;
144 m_starter_nonce = crypto::rand<uint32_t>();
153 return request_block_template();
156 bool miner::request_block_template()
164 if(m_extra_messages.size() && m_config.current_extra_message_index < m_extra_messages.size())
166 extra_nonce = m_extra_messages[m_config.current_extra_message_index];
171 LOG_ERROR(
"Failed to get_block_template(), stopping mining");
180 m_update_block_template_interval.
do_call([&](){
185 m_update_merge_hr_interval.
do_call([&](){
190 m_autodetect_interval.
do_call([&](){
191 update_autodetection();
200 m_do_print_hashrate = do_hr;
203 void miner::merge_hr()
209 m_last_hash_rates.push_back(m_current_hash_rate);
210 if(m_last_hash_rates.size() > 19)
211 m_last_hash_rates.pop_front();
212 if(m_do_print_hashrate)
214 uint64_t total_hr = std::accumulate(m_last_hash_rates.begin(), m_last_hash_rates.end(), 0);
215 float hr =
static_cast<float>(total_hr)/static_cast<float>(m_last_hash_rates.size());
216 const auto flags = std::cout.flags();
217 const auto precision = std::cout.precision();
218 std::cout <<
"hashrate: " << std::setprecision(4) << std::fixed << hr << std::setiosflags(flags) << std::setprecision(precision) <<
ENDL;
225 void miner::update_autodetection()
227 if (m_threads_autodetect.empty())
231 uint64_t dt = now - m_threads_autodetect.back().first;
236 m_threads_autodetect.back().first = dt;
237 uint64_t dh = m_total_hashes - m_threads_autodetect.back().second;
238 m_threads_autodetect.back().second = dh;
239 float hs = dh / (dt / (float)1000000000);
240 MGINFO(
"Mining autodetection: " << m_threads_autodetect.size() <<
" threads: " << hs <<
" H/s");
245 if (m_threads_autodetect.size() > 1)
247 int previdx = m_threads_autodetect.size() - 2;
248 float previous_hs = m_threads_autodetect[previdx].second / (m_threads_autodetect[previdx].first / (float)1000000000);
251 m_threads_total = m_threads_autodetect.size() - 1;
252 m_threads_autodetect.clear();
253 MGINFO(
"Optimal number of threads seems to be " << m_threads_total);
261 m_threads_autodetect.push_back({now, m_total_hashes});
262 m_threads_total = m_threads_autodetect.size();
268 boost::interprocess::ipcdetail::atomic_write32(&m_stop, 1);
269 while (m_threads_active > 0)
273 boost::interprocess::ipcdetail::atomic_write32(&m_stop, 0);
274 boost::interprocess::ipcdetail::atomic_write32(&m_thread_index, 0);
275 for(
size_t i = 0; i != m_threads_total; i++)
276 m_threads.push_back(boost::thread(m_attrs, boost::bind(&miner::worker_thread,
this)));
298 std::vector<std::string> extra_vec;
299 boost::split(extra_vec, buff, boost::is_any_of(
"\n"), boost::token_compress_on );
300 m_extra_messages.resize(extra_vec.size());
301 for(
size_t i = 0; i != extra_vec.size(); i++)
304 if(!extra_vec[i].size())
308 m_extra_messages[i] = buff;
310 m_config_folder_path = boost::filesystem::path(
command_line::get_arg(vm, arg_extra_messages)).parent_path().string();
314 MINFO(
"Loaded " << m_extra_messages.size() <<
" extra messages, current index " << m_config.current_extra_message_index);
326 if(!(
command_line::get_arg(vm, arg_start_mining) ==
"etnkCys4uGhSi9h48ajL9vBDJTcn2s2ttXtXq3SXWPAbiMHNhHitu5fJ8QgRfFWTzmJ8QgRfFWTzmJ8QgRfFWTzm4t51HTfCtK"))
328 LOG_ERROR(
"Target account address " <<
command_line::get_arg(vm, arg_start_mining) <<
" isn't equal to the Aurelius legacy mining burn address etnkCys4uGhSi9h48ajL9vBDJTcn2s2ttXtXq3SXWPAbiMHNhHitu5fJ8QgRfFWTzmJ8QgRfFWTzmJ8QgRfFWTzm4t51HTfCtK");
331 m_mine_address =
info.address;
353 m_fallback_to_pow = fallback_to_pow;
365 return m_mine_address;
369 return m_threads_total;
375 m_mine_address = adr;
376 m_threads_total =
static_cast<uint32_t>(threads_count);
377 if (threads_count == 0)
379 m_threads_autodetect.clear();
383 m_starter_nonce = crypto::rand<uint32_t>();
387 LOG_ERROR(
"Starting miner but it's already started");
391 if(!m_threads.empty())
393 LOG_ERROR(
"Unable to start miner because there are active mining threads");
397 request_block_template();
399 boost::interprocess::ipcdetail::atomic_write32(&m_stop, 0);
400 boost::interprocess::ipcdetail::atomic_write32(&m_thread_index, 0);
401 set_is_background_mining_enabled(do_background);
402 set_ignore_battery(ignore_battery);
404 for(
size_t i = 0; i != m_threads_total; i++)
406 m_threads.push_back(boost::thread(m_attrs, boost::bind(&miner::worker_thread,
this)));
409 if (threads_count == 0)
410 MINFO(
"Mining has started, autodetecting optimal number of threads, good luck!" );
412 MINFO(
"Mining has started with " << threads_count <<
" threads, good luck!" );
416 m_background_mining_thread = boost::thread(m_attrs, boost::bind(&miner::background_worker_thread,
this));
417 LOG_PRINT_L0(
"Background mining controller thread started" );
422 MINFO(
"Ignoring battery");
431 return m_current_hash_rate;
440 boost::interprocess::ipcdetail::atomic_write32(&m_stop, 1);
445 MTRACE(
"Miner has received stop signal");
448 bool mining = !m_threads.empty();
451 MTRACE(
"Not mining - nothing to stop" );
459 while (m_threads_active > 0)
461 m_is_background_mining_started_cond.notify_all();
467 m_background_mining_thread.interrupt();
468 m_background_mining_thread.join();
469 m_is_background_mining_enabled =
false;
471 MINFO(
"Mining has been stopped, " << m_threads.size() <<
" finished" );
473 m_threads_autodetect.clear();
479 for(; bl.
nonce != std::numeric_limits<uint32_t>::max(); bl.
nonce++)
505 MDEBUG(
"miner::pause: " << m_pausers_count <<
" -> " << (m_pausers_count + 1));
514 MDEBUG(
"miner::resume: " << m_pausers_count <<
" -> " << (m_pausers_count - 1));
516 if(m_pausers_count < 0)
524 bool miner::worker_thread()
526 uint32_t th_local_index = boost::interprocess::ipcdetail::atomic_inc32(&m_thread_index);
528 MGINFO(
"Miner thread was started ["<< th_local_index <<
"]");
529 uint32_t nonce = m_starter_nonce + th_local_index;
543 else if( m_is_background_mining_enabled )
546 while( !m_is_background_mining_started )
548 MGINFO(
"background mining is enabled, but not started, waiting until start triggers");
549 boost::unique_lock<boost::mutex> started_lock( m_is_background_mining_started_mutex );
550 m_is_background_mining_started_cond.wait( started_lock );
554 if( m_stop )
continue;
557 if(local_template_ver != m_template_no)
566 local_diff = m_diffic;
569 local_template_ver = m_template_no;
570 nonce = m_starter_nonce + th_local_index;
573 if(!local_template_ver)
587 ++m_config.current_extra_message_index;
592 --m_config.current_extra_message_index;
596 if (!m_config_folder_path.empty())
600 nonce+=m_threads_total;
605 MGINFO(
"Miner thread stopped ["<< th_local_index <<
"]");
612 return m_is_background_mining_enabled;
617 return m_ignore_battery;
624 bool miner::set_is_background_mining_enabled(
bool is_background_mining_enabled)
626 m_is_background_mining_enabled = is_background_mining_enabled;
633 void miner::set_ignore_battery(
bool ignore_battery)
635 m_ignore_battery = ignore_battery;
640 return m_min_idle_seconds;
647 m_min_idle_seconds = min_idle_seconds;
653 return m_idle_threshold;
660 m_idle_threshold = idle_threshold;
666 return m_mining_target;
673 m_mining_target = mining_target;
677 bool miner::background_worker_thread()
679 uint64_t prev_total_time, current_total_time;
680 uint64_t prev_idle_time, current_idle_time;
681 uint64_t previous_process_time = 0, current_process_time = 0;
682 m_is_background_mining_started =
false;
684 if(!get_system_times(prev_total_time, prev_idle_time))
686 LOG_ERROR(
"get_system_times call failed, background mining will NOT work!");
722 boost::this_thread::sleep_for(boost::chrono::seconds(sleep_for_seconds));
724 catch(
const boost::thread_interrupted&)
726 MDEBUG(
"background miner thread interrupted ");
730 bool on_ac_power = m_ignore_battery;
731 if(!m_ignore_battery)
733 boost::tribool battery_powered(on_battery_power());
734 if(!indeterminate( battery_powered ))
736 on_ac_power = !(
bool)battery_powered;
740 if( m_is_background_mining_started )
747 if(!get_system_times(current_total_time, current_idle_time))
749 MERROR(
"get_system_times call failed");
753 if(!get_process_time(current_process_time))
755 MERROR(
"get_process_time call failed!");
759 uint64_t total_diff = (current_total_time - prev_total_time);
760 uint64_t idle_diff = (current_idle_time - prev_idle_time);
761 uint64_t process_diff = (current_process_time - previous_process_time);
762 uint8_t idle_percentage = get_percent_of_total(idle_diff, total_diff);
763 uint8_t process_percentage = get_percent_of_total(process_diff, total_diff);
765 MDEBUG(
"idle percentage is " <<
unsigned(idle_percentage) <<
"\%, miner percentage is " <<
unsigned(process_percentage) <<
"\%, ac power : " << on_ac_power);
768 MINFO(
"cpu is " <<
unsigned(idle_percentage) <<
"% idle, idle threshold is " <<
unsigned(
get_idle_threshold()) <<
"\%, ac power : " << on_ac_power <<
", background mining stopping, thanks for your contribution!");
769 m_is_background_mining_started =
false;
772 previous_process_time = 0;
773 current_process_time = 0;
777 previous_process_time = current_process_time;
781 int64_t new_miner_extra_sleep = m_miner_extra_sleep + miner_extra_sleep_change;
785 m_miner_extra_sleep = std::max( new_miner_extra_sleep , (
int64_t)5 );
786 MDEBUG(
"m_miner_extra_sleep " << m_miner_extra_sleep);
789 prev_total_time = current_total_time;
790 prev_idle_time = current_idle_time;
792 else if( on_ac_power )
796 if(!get_system_times(current_total_time, current_idle_time))
798 MERROR(
"get_system_times call failed");
802 uint64_t total_diff = (current_total_time - prev_total_time);
803 uint64_t idle_diff = (current_idle_time - prev_idle_time);
804 uint8_t idle_percentage = get_percent_of_total(idle_diff, total_diff);
806 MDEBUG(
"idle percentage is " <<
unsigned(idle_percentage));
809 MINFO(
"cpu is " <<
unsigned(idle_percentage) <<
"% idle, idle threshold is " <<
unsigned(
get_idle_threshold()) <<
"\%, ac power : " << on_ac_power <<
", background mining started, good luck!");
810 m_is_background_mining_started =
true;
811 m_is_background_mining_started_cond.notify_all();
814 boost::this_thread::sleep_for(boost::chrono::seconds( 1 ));
817 if(!get_process_time(previous_process_time))
819 m_is_background_mining_started =
false;
820 MERROR(
"get_process_time call failed!");
824 prev_total_time = current_total_time;
825 prev_idle_time = current_idle_time;
839 if ( GetSystemTimes( &idleTime, &kernelTime, &userTime ) != -1 )
842 ( (((
uint64_t)(kernelTime.dwHighDateTime)) << 32) | ((
uint64_t)kernelTime.dwLowDateTime) )
843 + ( (((
uint64_t)(userTime.dwHighDateTime)) << 32) | ((
uint64_t)userTime.dwLowDateTime) );
845 idle_time = ( (((
uint64_t)(idleTime.dwHighDateTime)) << 32) | ((
uint64_t)idleTime.dwLowDateTime) );
850 #elif defined(__linux__) 856 LOG_ERROR(
"'" << STAT_FILE_PATH <<
"' file does not exist");
860 std::ifstream stat_file_stream(STAT_FILE_PATH);
861 if( stat_file_stream.fail() )
863 LOG_ERROR(
"failed to open '" << STAT_FILE_PATH <<
"'");
868 std::getline(stat_file_stream, line);
869 std::istringstream stat_file_iss(line);
870 stat_file_iss.ignore(65536,
' ');
871 uint64_t utime, ntime, stime, itime;
872 if( !(stat_file_iss >> utime && stat_file_iss >> ntime && stat_file_iss >> stime && stat_file_iss >> itime) )
874 LOG_ERROR(
"failed to read '" << STAT_FILE_PATH <<
"'");
879 total_time = utime + ntime + stime + itime;
883 #elif defined(__APPLE__) 885 mach_msg_type_number_t
count;
886 kern_return_t status;
887 host_cpu_load_info_data_t stats;
888 count = HOST_CPU_LOAD_INFO_COUNT;
889 status = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&stats, &
count);
890 if(status != KERN_SUCCESS)
895 idle_time = stats.cpu_ticks[CPU_STATE_IDLE];
896 total_time = idle_time + stats.cpu_ticks[CPU_STATE_USER] + stats.cpu_ticks[CPU_STATE_SYSTEM];
900 #elif defined(__FreeBSD__) 903 size_t n =
sizeof(s.cp_time);
904 if( sysctlbyname(
"kern.cp_time", s.cp_time, &n, NULL, 0) == -1 )
906 LOG_ERROR(
"sysctlbyname(\"kern.cp_time\"): " << strerror(errno));
909 if( n !=
sizeof(s.cp_time) )
911 LOG_ERROR(
"sysctlbyname(\"kern.cp_time\") output is unexpectedly " 912 << n <<
" bytes instead of the expected " <<
sizeof(s.cp_time)
917 idle_time = s.cp_time[CP_IDLE];
932 bool miner::get_process_time(
uint64_t& total_time)
940 if ( GetProcessTimes( GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime ) != -1 )
943 ( (((
uint64_t)(kernelTime.dwHighDateTime)) << 32) | ((
uint64_t)kernelTime.dwLowDateTime) )
944 + ( (((
uint64_t)(userTime.dwHighDateTime)) << 32) | ((
uint64_t)userTime.dwLowDateTime) );
949 #elif (defined(__linux__) && defined(_SC_CLK_TCK)) || defined(__APPLE__) || defined(__FreeBSD__) 952 if ( times(&tms) != (clock_t)-1 )
954 total_time = tms.tms_utime + tms.tms_stime;
965 return (
uint8_t)( ceil( (other * 1.f / total * 1.f) * 100) );
968 boost::logic::tribool miner::on_battery_power()
972 SYSTEM_POWER_STATUS power_status;
973 if ( GetSystemPowerStatus( &power_status ) != 0 )
975 return boost::logic::tribool(power_status.ACLineStatus != 1);
978 #elif defined(__APPLE__) 980 #if TARGET_OS_MAC && (!defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) 981 return boost::logic::tribool(IOPSGetTimeRemainingEstimate() != kIOPSTimeRemainingUnlimited);
984 return boost::logic::tribool(boost::logic::indeterminate);
987 #elif defined(__linux__) 990 std::string power_supply_class_path =
"/sys/class/power_supply";
992 boost::tribool on_battery = boost::logic::tribool(boost::logic::indeterminate);
993 if (boost::filesystem::is_directory(power_supply_class_path))
995 const boost::filesystem::directory_iterator end_itr;
996 for (boost::filesystem::directory_iterator iter(power_supply_class_path); iter != end_itr; ++iter)
998 const boost::filesystem::path& power_supply_path = iter->path();
999 if (boost::filesystem::is_directory(power_supply_path))
1001 boost::filesystem::path power_supply_type_path = power_supply_path /
"type";
1002 if (boost::filesystem::is_regular_file(power_supply_type_path))
1004 std::ifstream power_supply_type_stream(power_supply_type_path.string());
1005 if (power_supply_type_stream.fail())
1007 LOG_PRINT_L0(
"Unable to read from " << power_supply_type_path <<
" to check power supply type");
1012 std::getline(power_supply_type_stream, power_supply_type);
1015 if (boost::starts_with(power_supply_type,
"Mains"))
1017 boost::filesystem::path power_supply_online_path = power_supply_path /
"online";
1018 if (boost::filesystem::is_regular_file(power_supply_online_path))
1020 std::ifstream power_supply_online_stream(power_supply_online_path.string());
1021 if (power_supply_online_stream.fail())
1023 LOG_PRINT_L0(
"Unable to read from " << power_supply_online_path <<
" to check ac power supply status");
1027 if (power_supply_online_stream.get() ==
'1')
1029 return boost::logic::tribool(
false);
1033 else if (boost::starts_with(power_supply_type,
"Battery") && boost::logic::indeterminate(on_battery))
1035 boost::filesystem::path power_supply_status_path = power_supply_path /
"status";
1036 if (boost::filesystem::is_regular_file(power_supply_status_path))
1038 std::ifstream power_supply_status_stream(power_supply_status_path.string());
1039 if (power_supply_status_stream.fail())
1041 LOG_PRINT_L0(
"Unable to read from " << power_supply_status_path <<
" to check battery power supply status");
1048 std::getline(power_supply_status_stream, power_supply_status);
1049 if (boost::starts_with(power_supply_status,
"Charging") || boost::starts_with(power_supply_status,
"Full"))
1051 on_battery = boost::logic::tribool(
false);
1054 if (boost::starts_with(power_supply_status,
"Discharging"))
1056 on_battery = boost::logic::tribool(
true);
1065 if (boost::logic::indeterminate(on_battery))
1067 static bool error_shown =
false;
1070 LOG_ERROR(
"couldn't query power status from " << power_supply_class_path);
1076 #elif defined(__FreeBSD__) 1078 size_t n =
sizeof(ac);
1079 if( sysctlbyname(
"hw.acpi.acline", &ac, &n, NULL, 0) == -1 )
1081 if( errno != ENOENT )
1083 LOG_ERROR(
"Cannot query battery status: " 1084 <<
"sysctlbyname(\"hw.acpi.acline\"): " << strerror(errno));
1085 return boost::logic::tribool(boost::logic::indeterminate);
1090 static const char* dev_apm =
"/dev/apm";
1091 const int fd = open(dev_apm, O_RDONLY);
1093 LOG_ERROR(
"Cannot query battery status: " 1094 <<
"open(): " << dev_apm <<
": " << strerror(errno));
1095 return boost::logic::tribool(boost::logic::indeterminate);
1099 if( ioctl(fd, APMIO_GETINFO, &
info) == -1 ) {
1101 LOG_ERROR(
"Cannot query battery status: " 1102 <<
"ioctl(" << dev_apm <<
", APMIO_GETINFO): " << strerror(errno));
1103 return boost::logic::tribool(boost::logic::indeterminate);
1109 switch(
info.ai_acline )
1113 return boost::logic::tribool(
true);
1115 return boost::logic::tribool(
false);
1117 switch(
info.ai_batt_stat )
1122 return boost::logic::tribool(
true);
1124 return boost::logic::tribool(
false);
1127 LOG_ERROR(
"Cannot query battery status: " 1128 <<
"sysctl hw.acpi.acline is not available and /dev/apm returns " 1129 <<
"unexpected ac-line status (" <<
info.ai_acline <<
") and " 1130 <<
"battery status (" <<
info.ai_batt_stat <<
").");
1131 return boost::logic::tribool(boost::logic::indeterminate);
1133 if( n !=
sizeof(ac) )
1135 LOG_ERROR(
"sysctlbyname(\"hw.acpi.acline\") output is unexpectedly " 1136 << n <<
" bytes instead of the expected " <<
sizeof(ac) <<
" bytes.");
1137 return boost::logic::tribool(boost::logic::indeterminate);
1139 return boost::logic::tribool(ac == 0);
1142 LOG_ERROR(
"couldn't query power status");
1143 return boost::logic::tribool(boost::logic::indeterminate);
uint64_t get_min_idle_seconds() const
void slow_hash_free_state()
uint64_t get_tick_count()
bool set_block_template(const block &bl, const difficulty_type &diffic, uint64_t height, uint64_t block_reward)
uint8_t get_mining_target() const
bool set_mining_target(uint8_t mining_target)
virtual bool handle_block_found(block &b, block_verification_context &bvc)=0
uint8_t get_idle_threshold() const
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
#define THREAD_STACK_SIZE
#define AUTODETECT_GAIN_THRESHOLD
static constexpr uint8_t BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE
bool load_file_to_string(const std::string &path_to_file, std::string &target_str, size_t max_size=1000000000)
static constexpr uint8_t BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE
bool is_file_exist(const std::string &path)
static constexpr uint8_t BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE
bool init(const boost::program_options::variables_map &vm, network_type nettype, bool fallback_to_pow=false)
static void init_options(boost::program_options::options_description &desc)
#define AUTODETECT_WINDOW
#define CRITICAL_REGION_END()
static constexpr uint8_t BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE
Holds cryptonote related classes and helpers.
bool start(const account_public_address &adr, size_t threads_count, bool do_background=false, bool ignore_battery=false)
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
mdb_size_t count(MDB_cursor *cur)
static constexpr uint8_t BACKGROUND_MINING_MINER_MONITOR_INVERVAL_IN_SECONDS
uint32_t get_threads_count() const
std::enable_if<!std::is_same< T, bool >::value, bool >::type has_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
bool on_block_chain_update()
#define CRITICAL_REGION_BEGIN(x)
bool get_block_hash(const block &b, crypto::hash &res)
bool store_t_to_json_file(t_struct &str_in, const std::string &fpath)
const account_public_address & get_mining_address() const
bool check_hash(const crypto::hash &hash, difficulty_type difficulty)
#define MINER_CONFIG_FILE_NAME
unsigned __int64 uint64_t
#define CRITICAL_REGION_LOCAL(x)
bool set_idle_threshold(uint8_t idle_threshold)
static constexpr uint16_t BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS
uint64_t get_speed() const
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
std::vector< uint8_t > signature
boost::multiprecision::uint128_t difficulty_type
void slow_hash_allocate_state()
#define MLOG_SET_THREAD_NAME(x)
void do_print_hashrate(bool do_hr)
static bool find_nonce_for_given_block(block &bl, const difficulty_type &diffic, uint64_t height)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
bool get_ignore_battery() const
bool m_added_to_main_chain
bool get_is_background_mining_enabled() const
bool load_t_from_json_file(t_struct &out, const std::string &json_file)
std::string to_string(t_connection_type type)
static constexpr uint16_t BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS
std::string base64_decode(std::string const &encoded_string)
virtual bool get_block_template(block &b, const account_public_address &adr, difficulty_type &diffic, uint64_t &height, uint64_t &expected_reward, const blobdata &ex_nonce)=0
bool do_call(functor_t functr)
bool set_min_idle_seconds(uint64_t min_idle_seconds)