aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/bdb.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-06-20 08:44:42 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-06-20 08:41:19 -0400
commitfa021e9a5b7e930a3db0febb416942dea3a90a8f (patch)
tree87be616951b6bbad4ef1edf0ed2d93880f6715d4 /src/wallet/bdb.h
parentd4f9ae00252ba44909a61db0f606be6fddf904c1 (diff)
wallet: Remove confusing double return value ret+success
Also, remove redundant comments
Diffstat (limited to 'src/wallet/bdb.h')
-rw-r--r--src/wallet/bdb.h25
1 files changed, 6 insertions, 19 deletions
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 <typename K, typename T>
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 <typename K, typename T>
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 <typename K>
bool Erase(const K& key)
{
- // Key
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(1000);
ssKey << key;
- // Erase
return EraseKey(ssKey);
}
template <typename K>
bool Exists(const K& key)
{
- // Key
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(1000);
ssKey << key;
- // Exists
return HasKey(ssKey);
}