Make BerkeleyBatch::Recover and WalletBatch::RecoverKeysOnlyFilter standalone

Instead of having these be class static functions, just make them be
standalone. Also removes WalletBatch::Recover which just passed through
to BerkeleyBatch::Recover.
This commit is contained in:
Andrew Chow
2020-05-15 19:24:26 -04:00
parent 2741774214
commit b426c7764d
5 changed files with 9 additions and 26 deletions

View File

@@ -885,22 +885,7 @@ void MaybeCompactWalletDB()
fOneThread = false;
}
//
// Try to (very carefully!) recover wallet file if there is a problem.
//
bool WalletBatch::Recover(const fs::path& wallet_path, void *callbackDataIn, bool (*recoverKVcallback)(void* callbackData, CDataStream ssKey, CDataStream ssValue), std::string& out_backup_filename)
{
return BerkeleyBatch::Recover(wallet_path, callbackDataIn, recoverKVcallback, out_backup_filename);
}
bool WalletBatch::Recover(const fs::path& wallet_path, std::string& out_backup_filename)
{
// recover without a key filter callback
// results in recovering all record types
return WalletBatch::Recover(wallet_path, nullptr, nullptr, out_backup_filename);
}
bool WalletBatch::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
bool RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
{
CWallet *dummyWallet = reinterpret_cast<CWallet*>(callbackData);
std::string strType, strErr;
@@ -910,7 +895,7 @@ bool WalletBatch::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, C
LOCK(dummyWallet->cs_wallet);
fReadOK = ReadKeyValue(dummyWallet, ssKey, ssValue, strType, strErr);
}
if (!IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
if (!WalletBatch::IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
return false;
}
if (!fReadOK)