Skip to content

Commit beef966

Browse files
committed
[Wallet] remove unused code/conditions in ReadAtCursor
1 parent 41d8e78 commit beef966

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/wallet/db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
387387
while (fSuccess) {
388388
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
389389
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
390-
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
390+
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue);
391391
if (ret == DB_NOTFOUND) {
392392
pcursor->close();
393393
break;

src/wallet/db.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,17 @@ class CDB
228228
return pcursor;
229229
}
230230

231-
int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags = DB_NEXT)
231+
int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, bool setRange = false)
232232
{
233233
// Read at cursor
234234
Dbt datKey;
235-
if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) {
235+
unsigned int fFlags = DB_NEXT;
236+
if (setRange) {
236237
datKey.set_data(&ssKey[0]);
237238
datKey.set_size(ssKey.size());
239+
fFlags = DB_SET_RANGE;
238240
}
239241
Dbt datValue;
240-
if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) {
241-
datValue.set_data(&ssValue[0]);
242-
datValue.set_size(ssValue.size());
243-
}
244242
datKey.set_flags(DB_DBT_MALLOC);
245243
datValue.set_flags(DB_DBT_MALLOC);
246244
int ret = pcursor->get(&datKey, &datValue, fFlags);

src/wallet/walletdb.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,16 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
216216
Dbc* pcursor = GetCursor();
217217
if (!pcursor)
218218
throw runtime_error(std::string(__func__) + ": cannot create DB cursor");
219-
unsigned int fFlags = DB_SET_RANGE;
219+
bool setRange = true;
220220
while (true)
221221
{
222222
// Read next record
223223
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
224-
if (fFlags == DB_SET_RANGE)
224+
if (setRange)
225225
ssKey << std::make_pair(std::string("acentry"), std::make_pair((fAllAccounts ? string("") : strAccount), uint64_t(0)));
226226
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
227-
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
228-
fFlags = DB_NEXT;
227+
int ret = ReadAtCursor(pcursor, ssKey, ssValue, setRange);
228+
setRange = false;
229229
if (ret == DB_NOTFOUND)
230230
break;
231231
else if (ret != 0)

0 commit comments

Comments
 (0)