From fa021e9a5b7e930a3db0febb416942dea3a90a8f Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sat, 20 Jun 2020 08:44:42 -0400 Subject: wallet: Remove confusing double return value ret+success Also, remove redundant comments --- src/wallet/bdb.h | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/wallet/bdb.h') diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index c121bb4228..a2eaf95001 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -223,64 +223,51 @@ public: template bool Read(const K& key, T& value) { - // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; CDataStream ssValue(SER_DISK, CLIENT_VERSION); - bool success = false; - bool ret = ReadKey(ssKey, ssValue); - if (ret) { - // Unserialize value - try { - ssValue >> value; - success = true; - } catch (const std::exception&) { - // In this case success remains 'false' - } + if (!ReadKey(ssKey, ssValue)) return false; + try { + ssValue >> value; + return true; + } catch (const std::exception&) { + return false; } - return ret && success; } template bool Write(const K& key, const T& value, bool fOverwrite = true) { - // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; - // Value CDataStream ssValue(SER_DISK, CLIENT_VERSION); ssValue.reserve(10000); ssValue << value; - // Write return WriteKey(ssKey, ssValue, fOverwrite); } template bool Erase(const K& key) { - // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; - // Erase return EraseKey(ssKey); } template bool Exists(const K& key) { - // Key CDataStream ssKey(SER_DISK, CLIENT_VERSION); ssKey.reserve(1000); ssKey << key; - // Exists return HasKey(ssKey); } -- cgit v1.2.3