diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-03-19 10:25:12 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-03-19 12:40:26 +0000 |
commit | a6f1d8fc4c85ad6c7b15a7fdfc3b3bf11aa2bf18 (patch) | |
tree | 26de3c581c68f861966043cec4943db2b07968b7 /src/cryptonote_core | |
parent | Merge pull request #1886 (diff) | |
download | monero-a6f1d8fc4c85ad6c7b15a7fdfc3b3bf11aa2bf18.tar.xz |
core: call {prepare|cleanup}_handle_incoming_blocks when adding a mined block
This ensures that a batch can't also be started/stopped out of
sync by another thread and us getting in the middle
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index d53cacd8e..1b20776a5 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -887,11 +887,28 @@ namespace cryptonote m_miner.resume(); } //----------------------------------------------------------------------------------------------- + block_complete_entry get_block_complete_entry(block& b, tx_memory_pool &pool) + { + block_complete_entry bce; + bce.block = cryptonote::block_to_blob(b); + for (const auto &tx_hash: b.tx_hashes) + { + cryptonote::transaction tx; + CHECK_AND_ASSERT_THROW_MES(pool.get_transaction(tx_hash, tx), "Transaction not found in pool"); + bce.txs.push_back(cryptonote::tx_to_blob(tx)); + } + return bce; + } + //----------------------------------------------------------------------------------------------- bool core::handle_block_found(block& b) { block_verification_context bvc = boost::value_initialized<block_verification_context>(); m_miner.pause(); + std::list<block_complete_entry> blocks; + blocks.push_back(get_block_complete_entry(b, m_mempool)); + prepare_handle_incoming_blocks(blocks); m_blockchain_storage.add_new_block(b, bvc); + cleanup_handle_incoming_blocks(true); //anyway - update miner template update_miner_block_template(); m_miner.resume(); |