From beef966e365e16a9b041321e404f7cd21a4e999e Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Tue, 23 Aug 2016 15:36:23 +0200 Subject: [PATCH] [Wallet] remove unused code/conditions in ReadAtCursor --- src/wallet/db.cpp | 2 +- src/wallet/db.h | 10 ++++------ src/wallet/walletdb.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index cfd007ca1..652bbebde 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -387,7 +387,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) while (fSuccess) { CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssValue(SER_DISK, CLIENT_VERSION); - int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); + int ret = db.ReadAtCursor(pcursor, ssKey, ssValue); if (ret == DB_NOTFOUND) { pcursor->close(); break; diff --git a/src/wallet/db.h b/src/wallet/db.h index 01b8c71a0..a0f673ecf 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -228,19 +228,17 @@ protected: return pcursor; } - int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags = DB_NEXT) + int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, bool setRange = false) { // Read at cursor Dbt datKey; - if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { + unsigned int fFlags = DB_NEXT; + if (setRange) { datKey.set_data(&ssKey[0]); datKey.set_size(ssKey.size()); + fFlags = DB_SET_RANGE; } Dbt datValue; - if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { - datValue.set_data(&ssValue[0]); - datValue.set_size(ssValue.size()); - } datKey.set_flags(DB_DBT_MALLOC); datValue.set_flags(DB_DBT_MALLOC); int ret = pcursor->get(&datKey, &datValue, fFlags); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index f824492cb..a8072f1d2 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -216,16 +216,16 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list