Electroneum
cryptonote::miner Class Reference

#include <miner.h>

Collaboration diagram for cryptonote::miner:

Public Member Functions

 miner (i_miner_handler *phandler)
 
 ~miner ()
 
bool init (const boost::program_options::variables_map &vm, network_type nettype, bool fallback_to_pow=false)
 
bool set_block_template (const block &bl, const difficulty_type &diffic, uint64_t height, uint64_t block_reward)
 
bool on_block_chain_update ()
 
bool start (const account_public_address &adr, size_t threads_count, bool do_background=false, bool ignore_battery=false)
 
uint64_t get_speed () const
 
uint32_t get_threads_count () const
 
void send_stop_signal ()
 
bool stop ()
 
bool is_mining () const
 
const account_public_addressget_mining_address () const
 
bool on_idle ()
 
void on_synchronized ()
 
void pause ()
 
void resume ()
 
void do_print_hashrate (bool do_hr)
 
bool get_is_background_mining_enabled () const
 
bool get_ignore_battery () const
 
uint64_t get_min_idle_seconds () const
 
bool set_min_idle_seconds (uint64_t min_idle_seconds)
 
uint8_t get_idle_threshold () const
 
bool set_idle_threshold (uint8_t idle_threshold)
 
uint8_t get_mining_target () const
 
bool set_mining_target (uint8_t mining_target)
 
uint64_t get_block_reward () const
 

Static Public Member Functions

static void init_options (boost::program_options::options_description &desc)
 
static bool find_nonce_for_given_block (block &bl, const difficulty_type &diffic, uint64_t height)
 

Static Public Attributes

static constexpr uint8_t BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE = 90
 
static constexpr uint8_t BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE = 50
 
static constexpr uint8_t BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE = 99
 
static constexpr uint16_t BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS = 10
 
static constexpr uint16_t BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS = 10
 
static constexpr uint16_t BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS = 3600
 
static constexpr uint8_t BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE = 40
 
static constexpr uint8_t BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE = 5
 
static constexpr uint8_t BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE = 50
 
static constexpr uint8_t BACKGROUND_MINING_MINER_MONITOR_INVERVAL_IN_SECONDS = 10
 
static constexpr uint64_t BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS = 400
 
static constexpr uint64_t BACKGROUND_MINING_MIN_MINER_EXTRA_SLEEP_MILLIS = 5
 

Detailed Description

Definition at line 59 of file miner.h.

Constructor & Destructor Documentation

◆ miner()

cryptonote::miner::miner ( i_miner_handler phandler)

Definition at line 103 of file miner.cpp.

103  :m_stop(1),
104  m_template(boost::value_initialized<block>()),
105  m_template_no(0),
106  m_diffic(0),
107  m_thread_index(0),
108  m_phandler(phandler),
109  m_height(0),
110  m_threads_active(0),
111  m_pausers_count(0),
112  m_threads_total(0),
113  m_starter_nonce(0),
114  m_last_hr_merge_time(0),
115  m_hashes(0),
116  m_total_hashes(0),
117  m_do_print_hashrate(false),
118  m_do_mining(false),
119  m_current_hash_rate(0),
120  m_is_background_mining_enabled(false),
125  m_block_reward(0)
126  {
127  m_attrs.set_stack_size(THREAD_STACK_SIZE);
128  }
static constexpr uint16_t BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS
Definition: miner.h:95
#define THREAD_STACK_SIZE
static constexpr uint8_t BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE
Definition: miner.h:98
static constexpr uint64_t BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS
Definition: miner.h:102
static constexpr uint8_t BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE
Definition: miner.h:92

◆ ~miner()

cryptonote::miner::~miner ( )

Definition at line 130 of file miner.cpp.

131  {
132  try { stop(); }
133  catch (...) { /* ignore */ }
134  }
Here is the call graph for this function:

Member Function Documentation

◆ do_print_hashrate()

void cryptonote::miner::do_print_hashrate ( bool  do_hr)

Definition at line 198 of file miner.cpp.

199  {
200  m_do_print_hashrate = do_hr;
201  }

◆ find_nonce_for_given_block()

bool cryptonote::miner::find_nonce_for_given_block ( block bl,
const difficulty_type diffic,
uint64_t  height 
)
static

Definition at line 477 of file miner.cpp.

478  {
479  for(; bl.nonce != std::numeric_limits<uint32_t>::max(); bl.nonce++)
480  {
481  crypto::hash h;
482  get_block_longhash(bl, h, height);
483 
484  if(check_hash(h, diffic))
485  {
486  bl.invalidate_hashes();
487  return true;
488  }
489  }
490  bl.invalidate_hashes();
491  return false;
492  }
uint64_t height
Definition: blockchain.cpp:91
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
bool check_hash(const crypto::hash &hash, difficulty_type difficulty)
Definition: difficulty.cpp:203
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_reward()

uint64_t cryptonote::miner::get_block_reward ( ) const
inline

Definition at line 90 of file miner.h.

90 { return m_block_reward; }
Here is the caller graph for this function:

◆ get_idle_threshold()

uint8_t cryptonote::miner::get_idle_threshold ( ) const

Definition at line 651 of file miner.cpp.

652  {
653  return m_idle_threshold;
654  }
Here is the caller graph for this function:

◆ get_ignore_battery()

bool cryptonote::miner::get_ignore_battery ( ) const

Definition at line 615 of file miner.cpp.

616  {
617  return m_ignore_battery;
618  }
Here is the caller graph for this function:

◆ get_is_background_mining_enabled()

bool cryptonote::miner::get_is_background_mining_enabled ( ) const

Definition at line 610 of file miner.cpp.

611  {
612  return m_is_background_mining_enabled;
613  }
Here is the caller graph for this function:

◆ get_min_idle_seconds()

uint64_t cryptonote::miner::get_min_idle_seconds ( ) const

Definition at line 638 of file miner.cpp.

639  {
640  return m_min_idle_seconds;
641  }
Here is the caller graph for this function:

◆ get_mining_address()

const account_public_address & cryptonote::miner::get_mining_address ( ) const

Definition at line 363 of file miner.cpp.

364  {
365  return m_mine_address;
366  }
Here is the caller graph for this function:

◆ get_mining_target()

uint8_t cryptonote::miner::get_mining_target ( ) const

Definition at line 664 of file miner.cpp.

665  {
666  return m_mining_target;
667  }
Here is the caller graph for this function:

◆ get_speed()

uint64_t cryptonote::miner::get_speed ( ) const

Definition at line 428 of file miner.cpp.

429  {
430  if(is_mining()) {
431  return m_current_hash_rate;
432  }
433  else {
434  return 0;
435  }
436  }
bool is_mining() const
Definition: miner.cpp:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_threads_count()

uint32_t cryptonote::miner::get_threads_count ( ) const

Definition at line 368 of file miner.cpp.

368  {
369  return m_threads_total;
370  }
Here is the caller graph for this function:

◆ init()

bool cryptonote::miner::init ( const boost::program_options::variables_map &  vm,
network_type  nettype,
bool  fallback_to_pow = false 
)

Definition at line 291 of file miner.cpp.

292  {
293  if(command_line::has_arg(vm, arg_extra_messages))
294  {
295  std::string buff;
296  bool r = file_io_utils::load_file_to_string(command_line::get_arg(vm, arg_extra_messages), buff);
297  CHECK_AND_ASSERT_MES(r, false, "Failed to load file with extra messages: " << command_line::get_arg(vm, arg_extra_messages));
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++)
302  {
303  string_tools::trim(extra_vec[i]);
304  if(!extra_vec[i].size())
305  continue;
306  std::string buff = string_encoding::base64_decode(extra_vec[i]);
307  if(buff != "0")
308  m_extra_messages[i] = buff;
309  }
310  m_config_folder_path = boost::filesystem::path(command_line::get_arg(vm, arg_extra_messages)).parent_path().string();
311  m_config = AUTO_VAL_INIT(m_config);
312  const std::string filename = m_config_folder_path + "/" + MINER_CONFIG_FILE_NAME;
313  CHECK_AND_ASSERT_MES(epee::serialization::load_t_from_json_file(m_config, filename), false, "Failed to load data from " << filename);
314  MINFO("Loaded " << m_extra_messages.size() << " extra messages, current index " << m_config.current_extra_message_index);
315  }
316 
317  if(command_line::has_arg(vm, arg_start_mining))
318  {
319  address_parse_info info;
320  if(!cryptonote::get_account_address_from_str(info, nettype, command_line::get_arg(vm, arg_start_mining)) || info.is_subaddress)
321  {
322  LOG_ERROR("Target account address " << command_line::get_arg(vm, arg_start_mining) << " has wrong format, starting daemon canceled");
323  return false;
324  }
325  // just a safeguard for the legacy infrastructure
326  if(!(command_line::get_arg(vm, arg_start_mining) == "etnkCys4uGhSi9h48ajL9vBDJTcn2s2ttXtXq3SXWPAbiMHNhHitu5fJ8QgRfFWTzmJ8QgRfFWTzmJ8QgRfFWTzm4t51HTfCtK"))
327  {
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");
329  return false;
330  }
331  m_mine_address = info.address;
332  m_threads_total = 1;
333  m_do_mining = true;
334  if(command_line::has_arg(vm, arg_mining_threads))
335  {
336  m_threads_total = command_line::get_arg(vm, arg_mining_threads);
337  }
338  }
339 
340  // Background mining parameters
341  // Let init set all parameters even if background mining is not enabled, they can start later with params set
342  if(command_line::has_arg(vm, arg_bg_mining_enable))
343  set_is_background_mining_enabled( command_line::get_arg(vm, arg_bg_mining_enable) );
344  if(command_line::has_arg(vm, arg_bg_mining_ignore_battery))
345  set_ignore_battery( command_line::get_arg(vm, arg_bg_mining_ignore_battery) );
346  if(command_line::has_arg(vm, arg_bg_mining_min_idle_interval_seconds))
347  set_min_idle_seconds( command_line::get_arg(vm, arg_bg_mining_min_idle_interval_seconds) );
348  if(command_line::has_arg(vm, arg_bg_mining_idle_threshold_percentage))
349  set_idle_threshold( command_line::get_arg(vm, arg_bg_mining_idle_threshold_percentage) );
350  if(command_line::has_arg(vm, arg_bg_mining_miner_target_percentage))
351  set_mining_target( command_line::get_arg(vm, arg_bg_mining_miner_target_percentage) );
352 
353  m_fallback_to_pow = fallback_to_pow;
354 
355  return true;
356  }
#define MINFO(x)
Definition: misc_log_ex.h:75
bool set_mining_target(uint8_t mining_target)
Definition: miner.cpp:669
::std::string string
Definition: gtest-port.h:1097
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:181
bool load_file_to_string(const std::string &path_to_file, std::string &target_str, size_t max_size=1000000000)
std::string & trim(std::string &str)
Definition: string_tools.h:288
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)
Definition: command_line.h:258
#define MINER_CONFIG_FILE_NAME
bool set_idle_threshold(uint8_t idle_threshold)
Definition: miner.cpp:656
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
Definition: command_line.h:271
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
bool load_t_from_json_file(t_struct &out, const std::string &json_file)
std::string base64_decode(std::string const &encoded_string)
bool set_min_idle_seconds(uint64_t min_idle_seconds)
Definition: miner.cpp:643
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_options()

void cryptonote::miner::init_options ( boost::program_options::options_description &  desc)
static

Definition at line 279 of file miner.cpp.

280  {
281  command_line::add_arg(desc, arg_extra_messages);
282  command_line::add_arg(desc, arg_start_mining);
283  command_line::add_arg(desc, arg_mining_threads);
284  command_line::add_arg(desc, arg_bg_mining_enable);
285  command_line::add_arg(desc, arg_bg_mining_ignore_battery);
286  command_line::add_arg(desc, arg_bg_mining_min_idle_interval_seconds);
287  command_line::add_arg(desc, arg_bg_mining_idle_threshold_percentage);
288  command_line::add_arg(desc, arg_bg_mining_miner_target_percentage);
289  }
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
Definition: command_line.h:188
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_mining()

bool cryptonote::miner::is_mining ( ) const

Definition at line 358 of file miner.cpp.

359  {
360  return !m_stop;
361  }
Here is the caller graph for this function:

◆ on_block_chain_update()

bool cryptonote::miner::on_block_chain_update ( )

Definition at line 148 of file miner.cpp.

149  {
150  if(!is_mining())
151  return true;
152 
153  return request_block_template();
154  }
bool is_mining() const
Definition: miner.cpp:358
Here is the call graph for this function:

◆ on_idle()

bool cryptonote::miner::on_idle ( )

Definition at line 178 of file miner.cpp.

179  {
180  m_update_block_template_interval.do_call([&](){
181  if(is_mining())request_block_template();
182  return true;
183  });
184 
185  m_update_merge_hr_interval.do_call([&](){
186  merge_hr();
187  return true;
188  });
189 
190  m_autodetect_interval.do_call([&](){
191  update_autodetection();
192  return true;
193  });
194 
195  return true;
196  }
bool is_mining() const
Definition: miner.cpp:358
bool do_call(functor_t functr)
Definition: math_helper.h:263
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_synchronized()

void cryptonote::miner::on_synchronized ( )

Definition at line 494 of file miner.cpp.

495  {
496  if(m_do_mining)
497  {
498  start(m_mine_address, m_threads_total, get_is_background_mining_enabled(), get_ignore_battery());
499  }
500  }
bool start(const account_public_address &adr, size_t threads_count, bool do_background=false, bool ignore_battery=false)
Definition: miner.cpp:372
bool get_ignore_battery() const
Definition: miner.cpp:615
bool get_is_background_mining_enabled() const
Definition: miner.cpp:610
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pause()

void cryptonote::miner::pause ( )

Definition at line 502 of file miner.cpp.

503  {
504  CRITICAL_REGION_LOCAL(m_miners_count_lock);
505  MDEBUG("miner::pause: " << m_pausers_count << " -> " << (m_pausers_count + 1));
506  ++m_pausers_count;
507  if(m_pausers_count == 1 && is_mining())
508  MDEBUG("MINING PAUSED");
509  }
#define MDEBUG(x)
Definition: misc_log_ex.h:76
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228
bool is_mining() const
Definition: miner.cpp:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resume()

void cryptonote::miner::resume ( )

Definition at line 511 of file miner.cpp.

512  {
513  CRITICAL_REGION_LOCAL(m_miners_count_lock);
514  MDEBUG("miner::resume: " << m_pausers_count << " -> " << (m_pausers_count - 1));
515  --m_pausers_count;
516  if(m_pausers_count < 0)
517  {
518  m_pausers_count = 0;
519  }
520  if(!m_pausers_count && is_mining())
521  MDEBUG("MINING RESUMED");
522  }
#define MDEBUG(x)
Definition: misc_log_ex.h:76
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228
bool is_mining() const
Definition: miner.cpp:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_stop_signal()

void cryptonote::miner::send_stop_signal ( )

Definition at line 438 of file miner.cpp.

439  {
440  boost::interprocess::ipcdetail::atomic_write32(&m_stop, 1);
441  }
Here is the caller graph for this function:

◆ set_block_template()

bool cryptonote::miner::set_block_template ( const block bl,
const difficulty_type diffic,
uint64_t  height,
uint64_t  block_reward 
)

Definition at line 136 of file miner.cpp.

137  {
138  CRITICAL_REGION_LOCAL(m_template_lock);
139  m_template = bl;
140  m_diffic = di;
141  m_height = height;
142  m_block_reward = block_reward;
143  ++m_template_no;
144  m_starter_nonce = crypto::rand<uint32_t>();
145  return true;
146  }
uint64_t height
Definition: blockchain.cpp:91
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228

◆ set_idle_threshold()

bool cryptonote::miner::set_idle_threshold ( uint8_t  idle_threshold)

Definition at line 656 of file miner.cpp.

657  {
658  if(idle_threshold > BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE) return false;
659  if(idle_threshold < BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE) return false;
660  m_idle_threshold = idle_threshold;
661  return true;
662  }
static constexpr uint8_t BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE
Definition: miner.h:94
static constexpr uint8_t BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE
Definition: miner.h:93
Here is the caller graph for this function:

◆ set_min_idle_seconds()

bool cryptonote::miner::set_min_idle_seconds ( uint64_t  min_idle_seconds)

Definition at line 643 of file miner.cpp.

644  {
645  if(min_idle_seconds > BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS) return false;
646  if(min_idle_seconds < BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS) return false;
647  m_min_idle_seconds = min_idle_seconds;
648  return true;
649  }
static constexpr uint16_t BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS
Definition: miner.h:96
static constexpr uint16_t BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS
Definition: miner.h:97
Here is the caller graph for this function:

◆ set_mining_target()

bool cryptonote::miner::set_mining_target ( uint8_t  mining_target)

Definition at line 669 of file miner.cpp.

670  {
671  if(mining_target > BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE) return false;
672  if(mining_target < BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE) return false;
673  m_mining_target = mining_target;
674  return true;
675  }
static constexpr uint8_t BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE
Definition: miner.h:99
static constexpr uint8_t BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE
Definition: miner.h:100
Here is the caller graph for this function:

◆ start()

bool cryptonote::miner::start ( const account_public_address adr,
size_t  threads_count,
bool  do_background = false,
bool  ignore_battery = false 
)

Definition at line 372 of file miner.cpp.

373  {
374  m_block_reward = 0;
375  m_mine_address = adr;
376  m_threads_total = static_cast<uint32_t>(threads_count);
377  if (threads_count == 0)
378  {
379  m_threads_autodetect.clear();
380  m_threads_autodetect.push_back({epee::misc_utils::get_ns_count(), m_total_hashes});
381  m_threads_total = 1;
382  }
383  m_starter_nonce = crypto::rand<uint32_t>();
384  CRITICAL_REGION_LOCAL(m_threads_lock);
385  if(is_mining())
386  {
387  LOG_ERROR("Starting miner but it's already started");
388  return false;
389  }
390 
391  if(!m_threads.empty())
392  {
393  LOG_ERROR("Unable to start miner because there are active mining threads");
394  return false;
395  }
396 
397  request_block_template();//lets update block template
398 
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);
403 
404  for(size_t i = 0; i != m_threads_total; i++)
405  {
406  m_threads.push_back(boost::thread(m_attrs, boost::bind(&miner::worker_thread, this)));
407  }
408 
409  if (threads_count == 0)
410  MINFO("Mining has started, autodetecting optimal number of threads, good luck!" );
411  else
412  MINFO("Mining has started with " << threads_count << " threads, good luck!" );
413 
415  {
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" );
418  }
419 
420  if(get_ignore_battery())
421  {
422  MINFO("Ignoring battery");
423  }
424 
425  return true;
426  }
#define MINFO(x)
Definition: misc_log_ex.h:75
#define LOG_PRINT_L0(x)
Definition: misc_log_ex.h:99
uint64_t get_ns_count()
unsigned int uint32_t
Definition: stdint.h:126
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
bool get_ignore_battery() const
Definition: miner.cpp:615
bool get_is_background_mining_enabled() const
Definition: miner.cpp:610
bool is_mining() const
Definition: miner.cpp:358
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

bool cryptonote::miner::stop ( )

Definition at line 443 of file miner.cpp.

444  {
445  MTRACE("Miner has received stop signal");
446 
447  CRITICAL_REGION_LOCAL(m_threads_lock);
448  bool mining = !m_threads.empty();
449  if (!mining)
450  {
451  MTRACE("Not mining - nothing to stop" );
452  return true;
453  }
454 
456 
457  // In case background mining was active and the miner threads are waiting
458  // on the background miner to signal start.
459  while (m_threads_active > 0)
460  {
461  m_is_background_mining_started_cond.notify_all();
463  }
464 
465  // The background mining thread could be sleeping for a long time, so we
466  // interrupt it just in case
467  m_background_mining_thread.interrupt();
468  m_background_mining_thread.join();
469  m_is_background_mining_enabled = false;
470 
471  MINFO("Mining has been stopped, " << m_threads.size() << " finished" );
472  m_threads.clear();
473  m_threads_autodetect.clear();
474  return true;
475  }
void send_stop_signal()
Definition: miner.cpp:438
#define MTRACE(x)
Definition: misc_log_ex.h:77
#define MINFO(x)
Definition: misc_log_ex.h:75
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228
bool sleep_no_w(long ms)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE = 90
static

Definition at line 92 of file miner.h.

◆ BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS

constexpr uint16_t cryptonote::miner::BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS = 10
static

Definition at line 95 of file miner.h.

◆ BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS

constexpr uint64_t cryptonote::miner::BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS = 400
static

Definition at line 102 of file miner.h.

◆ BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE = 40
static

Definition at line 98 of file miner.h.

◆ BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE = 99
static

Definition at line 94 of file miner.h.

◆ BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS

constexpr uint16_t cryptonote::miner::BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS = 3600
static

Definition at line 97 of file miner.h.

◆ BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE = 50
static

Definition at line 100 of file miner.h.

◆ BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE = 50
static

Definition at line 93 of file miner.h.

◆ BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS

constexpr uint16_t cryptonote::miner::BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS = 10
static

Definition at line 96 of file miner.h.

◆ BACKGROUND_MINING_MIN_MINER_EXTRA_SLEEP_MILLIS

constexpr uint64_t cryptonote::miner::BACKGROUND_MINING_MIN_MINER_EXTRA_SLEEP_MILLIS = 5
static

Definition at line 103 of file miner.h.

◆ BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE = 5
static

Definition at line 99 of file miner.h.

◆ BACKGROUND_MINING_MINER_MONITOR_INVERVAL_IN_SECONDS

constexpr uint8_t cryptonote::miner::BACKGROUND_MINING_MINER_MONITOR_INVERVAL_IN_SECONDS = 10
static

Definition at line 101 of file miner.h.


The documentation for this class was generated from the following files: