Skip to content

Commit 65fb880

Browse files
committed
Combine BerkeleyEnvironment::Verify into BerkeleyDatabase::Verify
1 parent 9d4b3d8 commit 65fb880

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/wallet/bdb.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,6 @@ BerkeleyEnvironment::BerkeleyEnvironment()
232232
fMockDb = true;
233233
}
234234

235-
bool BerkeleyEnvironment::Verify(const std::string& strFile)
236-
{
237-
LOCK(cs_db);
238-
assert(mapFileUseCount.count(strFile) == 0);
239-
240-
Db db(dbenv.get(), 0);
241-
int result = db.verify(strFile.c_str(), nullptr, nullptr, 0);
242-
return result == 0;
243-
}
244-
245235
BerkeleyBatch::SafeDbt::SafeDbt()
246236
{
247237
m_dbt.set_flags(DB_DBT_MALLOC);
@@ -295,7 +285,12 @@ bool BerkeleyDatabase::Verify(bilingual_str& errorStr)
295285

296286
if (fs::exists(file_path))
297287
{
298-
if (!env->Verify(strFile)) {
288+
LOCK(cs_db);
289+
assert(env->mapFileUseCount.count(strFile) == 0);
290+
291+
Db db(env->dbenv.get(), 0);
292+
int result = db.verify(strFile.c_str(), nullptr, nullptr, 0);
293+
if (result != 0) {
299294
errorStr = strprintf(_("%s corrupt. Try using the wallet tool bitcoin-wallet to salvage or restoring a backup."), file_path);
300295
return false;
301296
}

src/wallet/bdb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ class BerkeleyEnvironment
6767
bool IsDatabaseLoaded(const std::string& db_filename) const { return m_databases.find(db_filename) != m_databases.end(); }
6868
fs::path Directory() const { return strPath; }
6969

70-
bool Verify(const std::string& strFile);
71-
7270
bool Open(bilingual_str& error);
7371
void Close();
7472
void Flush(bool fShutdown);

0 commit comments

Comments
 (0)