From 92f33b9c5d76a7c32d4051c24b6b12fc6c55ecee Mon Sep 17 00:00:00 2001 From: Nils-Erik Frantzell Date: Mon, 25 Nov 2019 22:01:16 -0800 Subject: [PATCH] Remove misleading log messages when memoryDB is used --- libethereum/BlockChain.cpp | 18 +++++++++--------- libethereum/State.cpp | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 39709a42dfc..fd8efed7f3e 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -253,11 +253,11 @@ bool BlockChain::open(fs::path const& _path, WithExisting _we) catch (db::DatabaseError const& ex) { // Determine which database open call failed - auto const dbPath = !m_blocksDB.get() ? db_paths::blocksDatabasePath() : db_paths::extrasDatabasePath(); - LOG(m_loggerError) << "Error opening database: " << dbPath; - + auto const dbPath = + !m_blocksDB.get() ? db_paths::blocksDatabasePath() : db_paths::extrasDatabasePath(); if (db::isDiskDatabase()) { + LOG(m_loggerError) << "Error occurred when opening database: " << dbPath; db::DatabaseStatus const dbStatus = *boost::get_error_info(ex); if (fs::space(db_paths::chainPath()).available < 1024) { @@ -282,7 +282,8 @@ bool BlockChain::open(fs::path const& _path, WithExisting _we) } } - LOG(m_loggerError) << "Unknown error occurred. Exception details: " << ex.what(); + LOG(m_loggerError) << "Unknown error occurred when opening database. Exception details: " + << ex.what(); throw; } @@ -305,8 +306,7 @@ bool BlockChain::open(fs::path const& _path, WithExisting _we) // database because the extras database format may have changed m_lastBlockNumber = info(m_lastBlockHash).number(); - LOG(m_loggerInfo) << "Opened blockchain database (" << db_paths::chainPath() - << "). Latest: " << currentHash() + LOG(m_loggerInfo) << "Opened blockchain database. Latest: " << currentHash() << (!rebuildNeeded ? "(rebuild not needed)" : "*** REBUILD NEEDED ***"); return rebuildNeeded; } @@ -387,12 +387,12 @@ void BlockChain::rebuild( BOOST_THROW_EXCEPTION(DatabaseExists()); } fs::rename(db_paths::extrasDatabasePath(), db_paths::extrasDatabaseTemporaryPath()); - std::unique_ptr oldExtrasDB(db::DBFactory::create(db_paths::extrasDatabaseTemporaryPath())); + std::unique_ptr oldExtrasDB( + db::DBFactory::create(db_paths::extrasDatabaseTemporaryPath())); m_extrasDB = db::DBFactory::create(db_paths::extrasDatabasePath()); // Open a fresh state DB - Block s = genesisBlock( - State::openDB(db_paths::rootPath().string(), m_genesisHash, WithExisting::Kill)); + Block s = genesisBlock(State::openDB(db_paths::rootPath(), m_genesisHash, WithExisting::Kill)); // Clear all memos ready for replay. m_details.clear(); diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 1251b8c978b..019fc2bbd34 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -58,17 +58,16 @@ OverlayDB State::openDB(fs::path const& _basePath, h256 const& _genesisHash, Wit try { - clog(VerbosityTrace, "statedb") << "Opening state database (and creating if not present): " - << db_paths::stateDatabasePath(); + clog(VerbosityTrace, "statedb") << "Opening state database"; std::unique_ptr db = db::DBFactory::create(db_paths::stateDatabasePath()); return OverlayDB(std::move(db)); } catch (boost::exception const& ex) { - clog(VerbosityError, "statedb") - << "Error opening state database: " << db_paths::stateDatabasePath(); if (db::isDiskDatabase()) { + clog(VerbosityError, "statedb") + << "Error opening state database: " << db_paths::stateDatabasePath(); db::DatabaseStatus const dbStatus = *boost::get_error_info(ex); if (fs::space(db_paths::stateDatabasePath()).available < 1024) @@ -93,8 +92,9 @@ OverlayDB State::openDB(fs::path const& _basePath, h256 const& _genesisHash, Wit BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); } } - clog(VerbosityError, "statedb") << "Unknown error encountered. Exception details: " - << boost::diagnostic_information(ex); + clog(VerbosityError, "statedb") + << "Unknown error encountered when opening state database. Exception details: " + << boost::diagnostic_information(ex); throw; } }