Skip to content

Commit da039d2

Browse files
committed
Remove BDB dummy databases
1 parent 0103d64 commit da039d2

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

src/wallet/bdb.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const char* pszMode, bo
337337

338338
void BerkeleyDatabase::Open(const char* pszMode)
339339
{
340-
if (IsDummy()){
341-
return;
342-
}
343-
344340
bool fCreate = strchr(pszMode, 'c') != nullptr;
345341
unsigned int nFlags = DB_THREAD;
346342
if (fCreate)
@@ -472,9 +468,6 @@ void BerkeleyEnvironment::ReloadDbEnv()
472468

473469
bool BerkeleyDatabase::Rewrite(const char* pszSkip)
474470
{
475-
if (IsDummy()) {
476-
return true;
477-
}
478471
while (true) {
479472
{
480473
LOCK(cs_db);
@@ -602,9 +595,6 @@ void BerkeleyEnvironment::Flush(bool fShutdown)
602595

603596
bool BerkeleyDatabase::PeriodicFlush()
604597
{
605-
// There's nothing to do for dummy databases. Return true.
606-
if (IsDummy()) return true;
607-
608598
// Don't flush if we can't acquire the lock.
609599
TRY_LOCK(cs_db, lockDb);
610600
if (!lockDb) return false;
@@ -632,9 +622,6 @@ bool BerkeleyDatabase::PeriodicFlush()
632622

633623
bool BerkeleyDatabase::Backup(const std::string& strDest) const
634624
{
635-
if (IsDummy()) {
636-
return false;
637-
}
638625
while (true)
639626
{
640627
{
@@ -672,23 +659,17 @@ bool BerkeleyDatabase::Backup(const std::string& strDest) const
672659

673660
void BerkeleyDatabase::Flush()
674661
{
675-
if (!IsDummy()) {
676-
env->Flush(false);
677-
}
662+
env->Flush(false);
678663
}
679664

680665
void BerkeleyDatabase::Close()
681666
{
682-
if (!IsDummy()) {
683-
env->Flush(true);
684-
}
667+
env->Flush(true);
685668
}
686669

687670
void BerkeleyDatabase::ReloadDbEnv()
688671
{
689-
if (!IsDummy()) {
690-
env->ReloadDbEnv();
691-
}
672+
env->ReloadDbEnv();
692673
}
693674

694675
bool BerkeleyBatch::StartCursor()

src/wallet/bdb.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ class BerkeleyBatch;
9898
class BerkeleyDatabase : public WalletDatabase
9999
{
100100
public:
101-
/** Create dummy DB handle */
102-
BerkeleyDatabase() : WalletDatabase(), env(nullptr)
103-
{
104-
}
101+
BerkeleyDatabase() = delete;
105102

106103
/** Create DB handle to real database */
107104
BerkeleyDatabase(std::shared_ptr<BerkeleyEnvironment> env, std::string filename) :
@@ -166,14 +163,6 @@ class BerkeleyDatabase : public WalletDatabase
166163

167164
/** Make a BerkeleyBatch connected to this database */
168165
std::unique_ptr<DatabaseBatch> MakeBatch(const char* mode = "r+", bool flush_on_close = true) override;
169-
170-
private:
171-
172-
/** Return whether this database handle is a dummy for testing.
173-
* Only to be used at a low level, application should ideally not care
174-
* about this.
175-
*/
176-
bool IsDummy() const { return env == nullptr; }
177166
};
178167

179168
/** RAII class that provides access to a Berkeley database */

0 commit comments

Comments
 (0)