Skip to content

Commit

Permalink
Merge pull request monero-project#22 from electroneumRepo/feature/imp…
Browse files Browse the repository at this point in the history
…roved-sequential-mining

Pause miner when a block is found locally & resume mining when a bloc…
  • Loading branch information
Chris Harrison authored May 28, 2019
2 parents 4182010 + ed3ef98 commit b45af2d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/cryptonote_basic/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ namespace cryptonote
if(m_pausers_count < 0)
{
m_pausers_count = 0;
MERROR("Unexpected miner::resume() called");
}
if(!m_pausers_count && is_mining())
MDEBUG("MINING RESUMED");
Expand Down
1 change: 1 addition & 0 deletions src/cryptonote_basic/verification_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ namespace cryptonote
bool m_already_exists;
bool m_partial_block_reward;
bool m_validator_list_update_failed;
bool m_sequential_block;
};
}
1 change: 1 addition & 0 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3169,6 +3169,7 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash&
if(bl.signatory == m_db->get_block(bl.prev_id).signatory){
MERROR_VER("Block with id: " << id << std::endl << " has the same signatory as the previous block, which is not allowed");
bvc.m_verifivation_failed = true;
bvc.m_sequential_block = true;
goto leave;
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,10 @@ namespace cryptonote
cleanup_handle_incoming_blocks(true);
//anyway - update miner template
update_miner_block_template();
m_miner.resume();

CHECK_AND_ASSERT(!bvc.m_sequential_block, false);

m_miner.resume();

CHECK_AND_ASSERT_MES(!bvc.m_verifivation_failed, false, "mined block failed verification");
if(bvc.m_added_to_main_chain)
Expand Down Expand Up @@ -1102,8 +1104,14 @@ namespace cryptonote
}

add_new_block(b, bvc);
if(update_miner_blocktemplate && bvc.m_added_to_main_chain)
update_miner_block_template();

if(bvc.m_added_to_main_chain) {
m_miner.resume();

if(update_miner_blocktemplate)
update_miner_block_template();
}

return true;

CATCH_ENTRY_L0("core::handle_incoming_block()", false);
Expand Down

0 comments on commit b45af2d

Please sign in to comment.