diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-10-04 11:41:13 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-10-04 11:41:13 +0200 |
commit | fa1d5efb5a7038bc7c54687db3da3b0c8fb54157 (patch) | |
tree | 5a23088414f6401011128879dce17dfcbf3b976b /src/cryptonote_core | |
parent | Merge pull request #1167 (diff) | |
parent | Brackets to prevent premature return (diff) | |
download | monero-fa1d5efb5a7038bc7c54687db3da3b0c8fb54157.tar.xz |
Merge pull request #1168
10be903 Brackets to prevent premature return (NanoAkron)
fb1785a Brackets to ensure doesn't function prematurely return (NanoAkron)
8ed0d72 Moved logging to target functions rather than caller (NanoAkron)
442bfd1 Added messages at log level 2 to reflect deactivation procedure (NanoAkron)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 14 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 7 | ||||
-rw-r--r-- | src/cryptonote_core/miner.cpp | 5 | ||||
-rw-r--r-- | src/cryptonote_core/tx_pool.cpp | 19 |
4 files changed, 32 insertions, 13 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index badb1a335..b9b9e2fb9 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -387,7 +387,7 @@ bool Blockchain::init(BlockchainDB* db, HardFork*& hf, const bool testnet) //------------------------------------------------------------------ bool Blockchain::store_blockchain() { - LOG_PRINT_YELLOW("Blockchain::" << __func__, LOG_LEVEL_3); + LOG_PRINT_L3("Blockchain::" << __func__); // lock because the rpc_thread command handler also calls this CRITICAL_REGION_LOCAL(m_db->m_synchronization_lock); @@ -419,9 +419,10 @@ bool Blockchain::deinit() { LOG_PRINT_L3("Blockchain::" << __func__); - LOG_PRINT_L0("Closing IO Service."); - // stop async service - m_async_work_idle.reset(); + LOG_PRINT_L1("Stopping blockchain read/write activity"); + + // stop async service + m_async_work_idle.reset(); m_async_pool.join_all(); m_async_service.stop(); @@ -436,14 +437,15 @@ bool Blockchain::deinit() try { m_db->close(); + LOG_PRINT_L1("Local blockchain read/write activity stopped successfully"); } catch (const std::exception& e) { - LOG_PRINT_L0(std::string("Error closing blockchain db: ") + e.what()); + LOG_ERROR(std::string("Error closing blockchain db: ") + e.what()); } catch (...) { - LOG_PRINT_L0("There was an issue closing/storing the blockchain, shutting down now to prevent issues!"); + LOG_ERROR("There was an issue closing/storing the blockchain, shutting down now to prevent issues!"); } delete m_hardfork; diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 4abf6a898..5ea4d9fbc 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -228,14 +228,14 @@ namespace cryptonote LOG_PRINT_L1("Locking " << lock_path.string()); if (!db_lock.try_lock()) { - LOG_PRINT_L0("Failed to lock " << lock_path.string()); + LOG_ERROR("Failed to lock " << lock_path.string()); return false; } return true; } catch (const std::exception &e) { - LOG_PRINT_L0("Error trying to lock " << lock_path.string() << ": " << e.what()); + LOG_ERROR("Error trying to lock " << lock_path.string() << ": " << e.what()); return false; } } @@ -244,6 +244,7 @@ namespace cryptonote { db_lock.unlock(); db_lock = boost::interprocess::file_lock(); + LOG_PRINT_L1("Blockchain directory successfully unlocked"); return true; } //----------------------------------------------------------------------------------------------- @@ -387,7 +388,7 @@ namespace cryptonote } catch (const DB_ERROR& e) { - LOG_PRINT_L0("Error opening database: " << e.what()); + LOG_ERROR("Error opening database: " << e.what()); return false; } diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp index ec717a13d..6f4e706ed 100644 --- a/src/cryptonote_core/miner.cpp +++ b/src/cryptonote_core/miner.cpp @@ -278,8 +278,13 @@ namespace cryptonote //----------------------------------------------------------------------------------------------------- bool miner::stop() { + LOG_PRINT_L1("Miner has received stop signal"); + if (!is_mining()) + { + LOG_PRINT_L1("Not mining - nothing to stop" ); return true; + } send_stop_signal(); CRITICAL_REGION_LOCAL(m_threads_lock); diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 46fab4dcf..5bfa7eca6 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -689,7 +689,7 @@ namespace cryptonote bool res = tools::unserialize_obj_from_file(*this, state_file_path); if(!res) { - LOG_PRINT_L1("Failed to load memory pool from file " << state_file_path); + LOG_ERROR("Failed to load memory pool from file " << state_file_path); m_transactions.clear(); m_txs_by_fee.clear(); @@ -710,12 +710,17 @@ namespace cryptonote //TODO: investigate whether only ever returning true is correct bool tx_memory_pool::deinit() { + LOG_PRINT_L1("Received signal to deactivate memory pool store"); + if (m_config_folder.empty()) + { + LOG_PRINT_L1("Memory pool store already empty"); return true; + } if (!tools::create_directories_if_necessary(m_config_folder)) { - LOG_PRINT_L1("Failed to create data directory: " << m_config_folder); + LOG_ERROR("Failed to create memory pool data directory: " << m_config_folder); return false; } @@ -723,8 +728,14 @@ namespace cryptonote bool res = tools::serialize_obj_to_file(*this, state_file_path); if(!res) { - LOG_PRINT_L1("Failed to serialize memory pool to file " << state_file_path); + LOG_ERROR("Failed to serialize memory pool to file " << state_file_path); + return false; } - return true; + else + { + LOG_PRINT_L1("Memory pool store deactivated successfully"); + return true; + } + } } |