added mechanism to forcibly stop miner when crossing Carrot HF boundary, and allow mining to be restarted
This commit is contained in:
@@ -104,7 +104,9 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
miner::miner(i_miner_handler* phandler, const get_block_hash_t &gbh):m_stop(1),
|
miner::miner(i_miner_handler* phandler, const get_block_hash_t &gbh):
|
||||||
|
m_forced_stop(1),
|
||||||
|
m_stop(1),
|
||||||
m_template{},
|
m_template{},
|
||||||
m_template_no(0),
|
m_template_no(0),
|
||||||
m_diffic(0),
|
m_diffic(0),
|
||||||
@@ -176,7 +178,8 @@ namespace cryptonote
|
|||||||
if(!m_phandler->get_block_template(bl, m_mine_address, di, height, expected_reward, extra_nonce, seed_height, seed_hash))
|
if(!m_phandler->get_block_template(bl, m_mine_address, di, height, expected_reward, extra_nonce, seed_height, seed_hash))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Failed to get_block_template(), stopping mining");
|
LOG_ERROR("Failed to get_block_template(), stopping mining");
|
||||||
stop();
|
m_forced_stop = true;
|
||||||
|
m_stop = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
set_block_template(bl, di, height, expected_reward);
|
set_block_template(bl, di, height, expected_reward);
|
||||||
@@ -187,9 +190,14 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
m_update_block_template_interval.do_call([&](){
|
m_update_block_template_interval.do_call([&](){
|
||||||
if(is_mining()) {
|
if(is_mining()) {
|
||||||
if (!request_block_template()) {
|
// Request the block template
|
||||||
stop();
|
request_block_template();
|
||||||
return false;
|
} else {
|
||||||
|
// Check for forced stop
|
||||||
|
if (m_forced_stop) {
|
||||||
|
if (!m_threads_active) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -404,6 +412,7 @@ namespace cryptonote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_forced_stop = false;
|
||||||
m_stop = false;
|
m_stop = false;
|
||||||
m_thread_index = 0;
|
m_thread_index = 0;
|
||||||
set_is_background_mining_enabled(do_background);
|
set_is_background_mining_enabled(do_background);
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ namespace cryptonote
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::atomic<bool> m_forced_stop;
|
||||||
std::atomic<bool> m_stop;
|
std::atomic<bool> m_stop;
|
||||||
epee::critical_section m_template_lock;
|
epee::critical_section m_template_lock;
|
||||||
block m_template;
|
block m_template;
|
||||||
|
|||||||
Reference in New Issue
Block a user