From 429a7405622ef84c17ecc851d0a6ac0086218837 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Fri, 9 Jan 2015 07:29:05 -0500 Subject: [PATCH] throw inline functions need to keep exception type As it is useful for functions calling BlockchainDB functions to know whether an exception is expected (attempting to get a block that doesn't exist and counting it missing if not, to save time checking if it does, for example), the inline functions throw{0,1} need to keep the exception type information. Slight comment update due to copy/paste failure. --- src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp index 5b71dcf08..0184dbc58 100644 --- a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp +++ b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp @@ -39,13 +39,15 @@ using epee::string_tools::pod_to_hex; namespace { -inline void throw0(const std::exception &e) +template +inline void throw0(const T &e) { LOG_PRINT_L0(e.what()); throw e; } -inline void throw1(const std::exception &e) +template +inline void throw1(const T &e) { LOG_PRINT_L1(e.what()); throw e; @@ -814,7 +816,7 @@ difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& auto get_result = mdb_get(txn, m_block_diffs, &key, &result); if (get_result == MDB_NOTFOUND) { - throw0(DB_ERROR(std::string("Attempt to get cumulative difficulty from height ").append(boost::lexical_cast(height)).append(" failed -- block size not in db").c_str())); + throw0(DB_ERROR(std::string("Attempt to get cumulative difficulty from height ").append(boost::lexical_cast(height)).append(" failed -- difficulty not in db").c_str())); } else if (get_result) throw0(DB_ERROR("Error attempting to retrieve a cumulative difficulty from the db"));