mirror of
https://github.com/monero-project/monero.git
synced 2025-05-02 15:36:08 -04:00
Merge pull request #5185
59478c80
daemon: new mining_status command (moneromooo-monero)
This commit is contained in:
commit
429930534d
9 changed files with 134 additions and 7 deletions
|
@ -119,7 +119,8 @@ namespace cryptonote
|
|||
m_min_idle_seconds(BACKGROUND_MINING_DEFAULT_MIN_IDLE_INTERVAL_IN_SECONDS),
|
||||
m_idle_threshold(BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE),
|
||||
m_mining_target(BACKGROUND_MINING_DEFAULT_MINING_TARGET_PERCENTAGE),
|
||||
m_miner_extra_sleep(BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS)
|
||||
m_miner_extra_sleep(BACKGROUND_MINING_DEFAULT_MINER_EXTRA_SLEEP_MILLIS),
|
||||
m_block_reward(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -130,12 +131,13 @@ namespace cryptonote
|
|||
catch (...) { /* ignore */ }
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
bool miner::set_block_template(const block& bl, const difficulty_type& di, uint64_t height)
|
||||
bool miner::set_block_template(const block& bl, const difficulty_type& di, uint64_t height, uint64_t block_reward)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_template_lock);
|
||||
m_template = bl;
|
||||
m_diffic = di;
|
||||
m_height = height;
|
||||
m_block_reward = block_reward;
|
||||
++m_template_no;
|
||||
m_starter_nonce = crypto::rand<uint32_t>();
|
||||
return true;
|
||||
|
@ -167,7 +169,7 @@ namespace cryptonote
|
|||
LOG_ERROR("Failed to get_block_template(), stopping mining");
|
||||
return false;
|
||||
}
|
||||
set_block_template(bl, di, height);
|
||||
set_block_template(bl, di, height, expected_reward);
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
@ -359,6 +361,7 @@ namespace cryptonote
|
|||
//-----------------------------------------------------------------------------------------------------
|
||||
bool miner::start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs, bool do_background, bool ignore_battery)
|
||||
{
|
||||
m_block_reward = 0;
|
||||
m_mine_address = adr;
|
||||
m_threads_total = static_cast<uint32_t>(threads_count);
|
||||
if (threads_count == 0)
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace cryptonote
|
|||
~miner();
|
||||
bool init(const boost::program_options::variables_map& vm, network_type nettype);
|
||||
static void init_options(boost::program_options::options_description& desc);
|
||||
bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height);
|
||||
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, const boost::thread::attributes& attrs, bool do_background = false, bool ignore_battery = false);
|
||||
uint64_t get_speed() const;
|
||||
|
@ -85,6 +85,7 @@ namespace cryptonote
|
|||
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 { return m_block_reward; }
|
||||
|
||||
static constexpr uint8_t BACKGROUND_MINING_DEFAULT_IDLE_THRESHOLD_PERCENTAGE = 90;
|
||||
static constexpr uint8_t BACKGROUND_MINING_MIN_IDLE_THRESHOLD_PERCENTAGE = 50;
|
||||
|
@ -169,5 +170,6 @@ namespace cryptonote
|
|||
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();
|
||||
std::atomic<uint64_t> m_block_reward;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue