Electroneum
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
cryptonote::miner Class Reference

#include <miner.h>

Collaboration diagram for cryptonote::miner:
Collaboration graph
[legend]

Classes

struct  miner_config
 

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
 

Private Member Functions

bool worker_thread ()
 
bool request_block_template ()
 
void merge_hr ()
 
void update_autodetection ()
 
bool set_is_background_mining_enabled (bool is_background_mining_enabled)
 
void set_ignore_battery (bool ignore_battery)
 
bool background_worker_thread ()
 

Static Private Member Functions

static bool get_system_times (uint64_t &total_time, uint64_t &idle_time)
 
static bool get_process_time (uint64_t &total_time)
 
static uint8_t get_percent_of_total (uint64_t some_time, uint64_t total_time)
 
static boost::logic::tribool on_battery_power ()
 

Private Attributes

volatile uint32_t m_stop
 
epee::critical_section m_template_lock
 
block m_template
 
std::atomic< uint32_t > m_template_no
 
std::atomic< uint32_t > m_starter_nonce
 
difficulty_type m_diffic
 
uint64_t m_height
 
volatile uint32_t m_thread_index
 
volatile uint32_t m_threads_total
 
std::atomic< uint32_t > m_threads_active
 
std::atomic< int32_t > m_pausers_count
 
epee::critical_section m_miners_count_lock
 
std::list< boost::thread > m_threads
 
epee::critical_section m_threads_lock
 
i_miner_handlerm_phandler
 
account_public_address m_mine_address
 
epee::math_helper::once_a_time_seconds< 5 > m_update_block_template_interval
 
epee::math_helper::once_a_time_seconds< 2 > m_update_merge_hr_interval
 
epee::math_helper::once_a_time_seconds< 1 > m_autodetect_interval
 
std::vector< blobdatam_extra_messages
 
miner_config m_config
 
std::string m_config_folder_path
 
std::atomic< uint64_t > m_last_hr_merge_time
 
std::atomic< uint64_t > m_hashes
 
std::atomic< uint64_t > m_total_hashes
 
std::atomic< uint64_t > m_current_hash_rate
 
epee::critical_section m_last_hash_rates_lock
 
std::list< uint64_t > m_last_hash_rates
 
bool m_do_print_hashrate
 
bool m_do_mining
 
std::vector< std::pair< uint64_t, uint64_t > > m_threads_autodetect
 
boost::thread::attributes m_attrs
 
std::atomic< boolm_is_background_mining_enabled
 
bool m_ignore_battery
 
boost::mutex m_is_background_mining_enabled_mutex
 
boost::condition_variable m_is_background_mining_enabled_cond
 
std::atomic< boolm_is_background_mining_started
 
boost::mutex m_is_background_mining_started_mutex
 
boost::condition_variable m_is_background_mining_started_cond
 
boost::thread m_background_mining_thread
 
uint64_t m_min_idle_seconds
 
uint8_t m_idle_threshold
 
uint8_t m_mining_target
 
std::atomic< uint64_t > m_miner_extra_sleep
 
std::atomic< uint64_t > m_block_reward
 
bool m_fallback_to_pow
 

Constructor & Destructor Documentation

◆ miner()

cryptonote::miner::miner ( i_miner_handler phandler)

◆ ~miner()

cryptonote::miner::~miner ( )

Member Function Documentation

◆ background_worker_thread()

bool cryptonote::miner::background_worker_thread ( )
private

◆ do_print_hashrate()

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

◆ find_nonce_for_given_block()

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

◆ get_block_reward()

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

◆ get_idle_threshold()

uint8_t cryptonote::miner::get_idle_threshold ( ) const

◆ get_ignore_battery()

bool cryptonote::miner::get_ignore_battery ( ) const

◆ get_is_background_mining_enabled()

bool cryptonote::miner::get_is_background_mining_enabled ( ) const

◆ get_min_idle_seconds()

uint64_t cryptonote::miner::get_min_idle_seconds ( ) const

◆ get_mining_address()

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

◆ get_mining_target()

uint8_t cryptonote::miner::get_mining_target ( ) const

◆ get_percent_of_total()

uint8_t cryptonote::miner::get_percent_of_total ( uint64_t  some_time,
uint64_t  total_time 
)
staticprivate

◆ get_process_time()

bool cryptonote::miner::get_process_time ( uint64_t &  total_time)
staticprivate

◆ get_speed()

uint64_t cryptonote::miner::get_speed ( ) const

◆ get_system_times()

bool cryptonote::miner::get_system_times ( uint64_t &  total_time,
uint64_t &  idle_time 
)
staticprivate

◆ get_threads_count()

uint32_t cryptonote::miner::get_threads_count ( ) const

◆ init()

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

◆ init_options()

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

◆ is_mining()

bool cryptonote::miner::is_mining ( ) const

◆ merge_hr()

void cryptonote::miner::merge_hr ( )
private

◆ on_battery_power()

boost::logic::tribool cryptonote::miner::on_battery_power ( )
staticprivate

◆ on_block_chain_update()

bool cryptonote::miner::on_block_chain_update ( )

◆ on_idle()

bool cryptonote::miner::on_idle ( )

◆ on_synchronized()

void cryptonote::miner::on_synchronized ( )

◆ pause()

void cryptonote::miner::pause ( )

◆ request_block_template()

bool cryptonote::miner::request_block_template ( )
private

◆ resume()

void cryptonote::miner::resume ( )

◆ send_stop_signal()

void cryptonote::miner::send_stop_signal ( )

◆ set_block_template()

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

◆ set_idle_threshold()

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

◆ set_ignore_battery()

void cryptonote::miner::set_ignore_battery ( bool  ignore_battery)
private

◆ set_is_background_mining_enabled()

bool cryptonote::miner::set_is_background_mining_enabled ( bool  is_background_mining_enabled)
private

This has differing behaviour depending on if mining has been started/etc. Note: add documentation

◆ set_min_idle_seconds()

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

◆ set_mining_target()

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

◆ start()

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

◆ stop()

bool cryptonote::miner::stop ( )

◆ update_autodetection()

void cryptonote::miner::update_autodetection ( )
private

◆ worker_thread()

bool cryptonote::miner::worker_thread ( )
private

Member Data Documentation

◆ BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE

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

◆ BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS

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

◆ BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS

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

◆ BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE

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

◆ BACKGROUND_MINING_MAX_IDLE_THRESHOLD_PERCENTAGE

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

◆ BACKGROUND_MINING_MAX_MIN_IDLE_INTERVAL_IN_SECONDS

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

◆ BACKGROUND_MINING_MAX_MINING_TARGET_PERCENTAGE

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

◆ BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE

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

◆ BACKGROUND_MINING_MIN_MIN_IDLE_INTERVAL_IN_SECONDS

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

◆ BACKGROUND_MINING_MIN_MINER_EXTRA_SLEEP_MILLIS

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

◆ BACKGROUND_MINING_MIN_MINING_TARGET_PERCENTAGE

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

◆ BACKGROUND_MINING_MINER_MONITOR_INVERVAL_IN_SECONDS

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

◆ m_attrs

boost::thread::attributes cryptonote::miner::m_attrs
private

◆ m_autodetect_interval

epee::math_helper::once_a_time_seconds<1> cryptonote::miner::m_autodetect_interval
private

◆ m_background_mining_thread

boost::thread cryptonote::miner::m_background_mining_thread
private

◆ m_block_reward

std::atomic<uint64_t> cryptonote::miner::m_block_reward
private

◆ m_config

miner_config cryptonote::miner::m_config
private

◆ m_config_folder_path

std::string cryptonote::miner::m_config_folder_path
private

◆ m_current_hash_rate

std::atomic<uint64_t> cryptonote::miner::m_current_hash_rate
private

◆ m_diffic

difficulty_type cryptonote::miner::m_diffic
private

◆ m_do_mining

bool cryptonote::miner::m_do_mining
private

◆ m_do_print_hashrate

bool cryptonote::miner::m_do_print_hashrate
private

◆ m_extra_messages

std::vector<blobdata> cryptonote::miner::m_extra_messages
private

◆ m_fallback_to_pow

bool cryptonote::miner::m_fallback_to_pow
private

◆ m_hashes

std::atomic<uint64_t> cryptonote::miner::m_hashes
private

◆ m_height

uint64_t cryptonote::miner::m_height
private

◆ m_idle_threshold

uint8_t cryptonote::miner::m_idle_threshold
private

◆ m_ignore_battery

bool cryptonote::miner::m_ignore_battery
private

◆ m_is_background_mining_enabled

std::atomic<bool> cryptonote::miner::m_is_background_mining_enabled
private

◆ m_is_background_mining_enabled_cond

boost::condition_variable cryptonote::miner::m_is_background_mining_enabled_cond
private

◆ m_is_background_mining_enabled_mutex

boost::mutex cryptonote::miner::m_is_background_mining_enabled_mutex
private

◆ m_is_background_mining_started

std::atomic<bool> cryptonote::miner::m_is_background_mining_started
private

◆ m_is_background_mining_started_cond

boost::condition_variable cryptonote::miner::m_is_background_mining_started_cond
private

◆ m_is_background_mining_started_mutex

boost::mutex cryptonote::miner::m_is_background_mining_started_mutex
private

◆ m_last_hash_rates

std::list<uint64_t> cryptonote::miner::m_last_hash_rates
private

◆ m_last_hash_rates_lock

epee::critical_section cryptonote::miner::m_last_hash_rates_lock
private

◆ m_last_hr_merge_time

std::atomic<uint64_t> cryptonote::miner::m_last_hr_merge_time
private

◆ m_min_idle_seconds

uint64_t cryptonote::miner::m_min_idle_seconds
private

◆ m_mine_address

account_public_address cryptonote::miner::m_mine_address
private

◆ m_miner_extra_sleep

std::atomic<uint64_t> cryptonote::miner::m_miner_extra_sleep
private

◆ m_miners_count_lock

epee::critical_section cryptonote::miner::m_miners_count_lock
private

◆ m_mining_target

uint8_t cryptonote::miner::m_mining_target
private

◆ m_pausers_count

std::atomic<int32_t> cryptonote::miner::m_pausers_count
private

◆ m_phandler

i_miner_handler* cryptonote::miner::m_phandler
private

◆ m_starter_nonce

std::atomic<uint32_t> cryptonote::miner::m_starter_nonce
private

◆ m_stop

volatile uint32_t cryptonote::miner::m_stop
private

◆ m_template

block cryptonote::miner::m_template
private

◆ m_template_lock

epee::critical_section cryptonote::miner::m_template_lock
private

◆ m_template_no

std::atomic<uint32_t> cryptonote::miner::m_template_no
private

◆ m_thread_index

volatile uint32_t cryptonote::miner::m_thread_index
private

◆ m_threads

std::list<boost::thread> cryptonote::miner::m_threads
private

◆ m_threads_active

std::atomic<uint32_t> cryptonote::miner::m_threads_active
private

◆ m_threads_autodetect

std::vector<std::pair<uint64_t, uint64_t> > cryptonote::miner::m_threads_autodetect
private

◆ m_threads_lock

epee::critical_section cryptonote::miner::m_threads_lock
private

◆ m_threads_total

volatile uint32_t cryptonote::miner::m_threads_total
private

◆ m_total_hashes

std::atomic<uint64_t> cryptonote::miner::m_total_hashes
private

◆ m_update_block_template_interval

epee::math_helper::once_a_time_seconds<5> cryptonote::miner::m_update_block_template_interval
private

◆ m_update_merge_hr_interval

epee::math_helper::once_a_time_seconds<2> cryptonote::miner::m_update_merge_hr_interval
private

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