diff options
author | Andrew Chow <github@achow101.com> | 2022-11-29 22:34:26 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2022-12-16 12:35:54 -0500 |
commit | 4aebd832a405090c2608e4b60bb4f34501bcea61 (patch) | |
tree | 81685d6a591416a0560d0e94d4003a5f2fec8593 /src/wallet/walletdb.cpp | |
parent | d79e8dcf2981ef1964a2fde8c472b5de1ca1c963 (diff) | |
download | bitcoin-4aebd832a405090c2608e4b60bb4f34501bcea61.tar.xz |
db: Change DatabaseCursor::Next to return status enum
Next()'s result is a tri-state - failed, more to go, complete. Replace
the way that this is returned with an enum with values FAIL, MORE, and
DONE rather than with two booleans.
Diffstat (limited to 'src/wallet/walletdb.cpp')
-rw-r--r-- | src/wallet/walletdb.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 1272b5378a..79700f0667 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -824,13 +824,10 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) // Read next record CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssValue(SER_DISK, CLIENT_VERSION); - bool complete; - bool ret = cursor->Next(ssKey, ssValue, complete); - if (complete) { + DatabaseCursor::Status status = cursor->Next(ssKey, ssValue); + if (status == DatabaseCursor::Status::DONE) { break; - } - else if (!ret) - { + } else if (status == DatabaseCursor::Status::FAIL) { cursor.reset(); pwallet->WalletLogPrintf("Error reading next record from wallet database\n"); return DBErrors::CORRUPT; @@ -998,11 +995,10 @@ DBErrors WalletBatch::FindWalletTx(std::vector<uint256>& vTxHash, std::list<CWal // Read next record CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssValue(SER_DISK, CLIENT_VERSION); - bool complete; - bool ret = cursor->Next(ssKey, ssValue, complete); - if (complete) { + DatabaseCursor::Status status = cursor->Next(ssKey, ssValue); + if (status == DatabaseCursor::Status::DONE) { break; - } else if (!ret) { + } else if (status == DatabaseCursor::Status::FAIL) { LogPrintf("Error reading next record from wallet database\n"); return DBErrors::CORRUPT; } @@ -1125,13 +1121,10 @@ bool WalletBatch::EraseRecords(const std::unordered_set<std::string>& types) // Read next record CDataStream key(SER_DISK, CLIENT_VERSION); CDataStream value(SER_DISK, CLIENT_VERSION); - bool complete; - bool ret = cursor->Next(key, value, complete); - if (complete) { + DatabaseCursor::Status status = cursor->Next(key, value); + if (status == DatabaseCursor::Status::DONE) { break; - } - else if (!ret) - { + } else if (status == DatabaseCursor::Status::FAIL) { return false; } |