Skip to content

Commit d8e9ca6

Browse files
committed
walletdb: Move Rewrite into BerkeleyDatabase
Make Rewrite actually a member of BerkeleyDatabase instead of a static function in BerkeleyBatch
1 parent 91d1091 commit d8e9ca6

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/wallet/bdb.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,11 @@ void BerkeleyEnvironment::ReloadDbEnv()
484484
Open(true);
485485
}
486486

487-
bool BerkeleyBatch::Rewrite(BerkeleyDatabase& database, const char* pszSkip)
487+
bool BerkeleyDatabase::Rewrite(const char* pszSkip)
488488
{
489-
if (database.IsDummy()) {
489+
if (IsDummy()) {
490490
return true;
491491
}
492-
BerkeleyEnvironment *env = database.env.get();
493-
const std::string& strFile = database.strFile;
494492
while (true) {
495493
{
496494
LOCK(cs_db);
@@ -504,7 +502,7 @@ bool BerkeleyBatch::Rewrite(BerkeleyDatabase& database, const char* pszSkip)
504502
LogPrintf("BerkeleyBatch::Rewrite: Rewriting %s...\n", strFile);
505503
std::string strFileRes = strFile + ".rewrite";
506504
{ // surround usage of db with extra {}
507-
BerkeleyBatch db(database, "r");
505+
BerkeleyBatch db(*this, "r");
508506
std::unique_ptr<Db> pdbCopy = MakeUnique<Db>(env->dbenv.get(), 0);
509507

510508
int ret = pdbCopy->open(nullptr, // Txn pointer
@@ -654,11 +652,6 @@ bool BerkeleyDatabase::PeriodicFlush()
654652
return ret;
655653
}
656654

657-
bool BerkeleyDatabase::Rewrite(const char* pszSkip)
658-
{
659-
return BerkeleyBatch::Rewrite(*this, pszSkip);
660-
}
661-
662655
bool BerkeleyDatabase::Backup(const std::string& strDest) const
663656
{
664657
if (IsDummy()) {

src/wallet/bdb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,6 @@ class BerkeleyBatch
287287
bool TxnBegin();
288288
bool TxnCommit();
289289
bool TxnAbort();
290-
291-
bool static Rewrite(BerkeleyDatabase& database, const char* pszSkip = nullptr);
292290
};
293291

294292
std::string BerkeleyDatabaseVersion();

0 commit comments

Comments
 (0)