diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-09-02 11:30:57 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-09-02 11:30:57 +0200 |
commit | 1e57e48342f66efe215b306aaf902a0e41b3629c (patch) | |
tree | 15f0cd3bed84c680f5b16041b241a6cdcc823999 /src/cryptonote_core | |
parent | Merge pull request #2370 (diff) | |
parent | cryptonote_protocol: error handling on cleanup_handle_incoming_blocks (diff) | |
download | monero-1e57e48342f66efe215b306aaf902a0e41b3629c.tar.xz |
Merge pull request #2372
c867357a cryptonote_protocol: error handling on cleanup_handle_incoming_blocks (moneromooo-monero)
ce901fcb Fix blockchain_import wedge on exception in cleanup_handle_incoming_blocks (moneromooo-monero)
84fa015e core: guard against exceptions in handle_incoming_{block,tx} (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 17 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 13 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index c1faa703f..93a4e26f8 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3582,12 +3582,23 @@ void Blockchain::block_longhash_worker(uint64_t height, const std::vector<block> //------------------------------------------------------------------ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync) { + bool success = false; + MTRACE("Blockchain::" << __func__); CRITICAL_REGION_BEGIN(m_blockchain_lock); TIME_MEASURE_START(t1); - m_db->batch_stop(); - if (m_sync_counter > 0) + try + { + m_db->batch_stop(); + success = true; + } + catch (const std::exception &e) + { + MERROR("Exception in cleanup_handle_incoming_blocks: " << e.what()); + } + + if (success && m_sync_counter > 0) { if (force_sync) { @@ -3622,7 +3633,7 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync) CRITICAL_REGION_END(); m_tx_pool.unlock(); - return true; + return success; } //------------------------------------------------------------------ diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index e58cf7424..73ce88c79 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -583,6 +583,8 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::handle_incoming_txs(const std::list<blobdata>& tx_blobs, std::vector<tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) { + TRY_ENTRY(); + struct result { bool res; cryptonote::transaction tx; crypto::hash hash; crypto::hash prefix_hash; bool in_txpool; bool in_blockchain; }; std::vector<result> results(tx_blobs.size()); @@ -636,6 +638,8 @@ namespace cryptonote MDEBUG("tx added: " << results[i].hash); } return ok; + + CATCH_ENTRY_L0("core::handle_incoming_txs()", false); } //----------------------------------------------------------------------------------------------- bool core::handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) @@ -1062,17 +1066,20 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::cleanup_handle_incoming_blocks(bool force_sync) { + bool success = false; try { - m_blockchain_storage.cleanup_handle_incoming_blocks(force_sync); + success = m_blockchain_storage.cleanup_handle_incoming_blocks(force_sync); } catch (...) {} m_incoming_tx_lock.unlock(); - return true; + return success; } //----------------------------------------------------------------------------------------------- bool core::handle_incoming_block(const blobdata& block_blob, block_verification_context& bvc, bool update_miner_blocktemplate) { + TRY_ENTRY(); + // load json & DNS checkpoints every 10min/hour respectively, // and verify them with respect to what blocks we already have CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints."); @@ -1096,6 +1103,8 @@ namespace cryptonote if(update_miner_blocktemplate && bvc.m_added_to_main_chain) update_miner_block_template(); return true; + + CATCH_ENTRY_L0("core::handle_incoming_block()", false); } //----------------------------------------------------------------------------------------------- // Used by the RPC server to check the size of an incoming |