mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
Remove BDB dummy databases
This commit is contained in:
parent
0103d6434e
commit
da039d2a91
2 changed files with 4 additions and 34 deletions
|
@ -337,10 +337,6 @@ BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const char* pszMode, bo
|
||||||
|
|
||||||
void BerkeleyDatabase::Open(const char* pszMode)
|
void BerkeleyDatabase::Open(const char* pszMode)
|
||||||
{
|
{
|
||||||
if (IsDummy()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fCreate = strchr(pszMode, 'c') != nullptr;
|
bool fCreate = strchr(pszMode, 'c') != nullptr;
|
||||||
unsigned int nFlags = DB_THREAD;
|
unsigned int nFlags = DB_THREAD;
|
||||||
if (fCreate)
|
if (fCreate)
|
||||||
|
@ -472,9 +468,6 @@ void BerkeleyEnvironment::ReloadDbEnv()
|
||||||
|
|
||||||
bool BerkeleyDatabase::Rewrite(const char* pszSkip)
|
bool BerkeleyDatabase::Rewrite(const char* pszSkip)
|
||||||
{
|
{
|
||||||
if (IsDummy()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
while (true) {
|
while (true) {
|
||||||
{
|
{
|
||||||
LOCK(cs_db);
|
LOCK(cs_db);
|
||||||
|
@ -602,9 +595,6 @@ void BerkeleyEnvironment::Flush(bool fShutdown)
|
||||||
|
|
||||||
bool BerkeleyDatabase::PeriodicFlush()
|
bool BerkeleyDatabase::PeriodicFlush()
|
||||||
{
|
{
|
||||||
// There's nothing to do for dummy databases. Return true.
|
|
||||||
if (IsDummy()) return true;
|
|
||||||
|
|
||||||
// Don't flush if we can't acquire the lock.
|
// Don't flush if we can't acquire the lock.
|
||||||
TRY_LOCK(cs_db, lockDb);
|
TRY_LOCK(cs_db, lockDb);
|
||||||
if (!lockDb) return false;
|
if (!lockDb) return false;
|
||||||
|
@ -632,9 +622,6 @@ bool BerkeleyDatabase::PeriodicFlush()
|
||||||
|
|
||||||
bool BerkeleyDatabase::Backup(const std::string& strDest) const
|
bool BerkeleyDatabase::Backup(const std::string& strDest) const
|
||||||
{
|
{
|
||||||
if (IsDummy()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -672,23 +659,17 @@ bool BerkeleyDatabase::Backup(const std::string& strDest) const
|
||||||
|
|
||||||
void BerkeleyDatabase::Flush()
|
void BerkeleyDatabase::Flush()
|
||||||
{
|
{
|
||||||
if (!IsDummy()) {
|
|
||||||
env->Flush(false);
|
env->Flush(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BerkeleyDatabase::Close()
|
void BerkeleyDatabase::Close()
|
||||||
{
|
{
|
||||||
if (!IsDummy()) {
|
|
||||||
env->Flush(true);
|
env->Flush(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BerkeleyDatabase::ReloadDbEnv()
|
void BerkeleyDatabase::ReloadDbEnv()
|
||||||
{
|
{
|
||||||
if (!IsDummy()) {
|
|
||||||
env->ReloadDbEnv();
|
env->ReloadDbEnv();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BerkeleyBatch::StartCursor()
|
bool BerkeleyBatch::StartCursor()
|
||||||
|
|
|
@ -98,10 +98,7 @@ class BerkeleyBatch;
|
||||||
class BerkeleyDatabase : public WalletDatabase
|
class BerkeleyDatabase : public WalletDatabase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Create dummy DB handle */
|
BerkeleyDatabase() = delete;
|
||||||
BerkeleyDatabase() : WalletDatabase(), env(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create DB handle to real database */
|
/** Create DB handle to real database */
|
||||||
BerkeleyDatabase(std::shared_ptr<BerkeleyEnvironment> env, std::string filename) :
|
BerkeleyDatabase(std::shared_ptr<BerkeleyEnvironment> env, std::string filename) :
|
||||||
|
@ -166,14 +163,6 @@ public:
|
||||||
|
|
||||||
/** Make a BerkeleyBatch connected to this database */
|
/** Make a BerkeleyBatch connected to this database */
|
||||||
std::unique_ptr<DatabaseBatch> MakeBatch(const char* mode = "r+", bool flush_on_close = true) override;
|
std::unique_ptr<DatabaseBatch> MakeBatch(const char* mode = "r+", bool flush_on_close = true) override;
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/** Return whether this database handle is a dummy for testing.
|
|
||||||
* Only to be used at a low level, application should ideally not care
|
|
||||||
* about this.
|
|
||||||
*/
|
|
||||||
bool IsDummy() const { return env == nullptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** RAII class that provides access to a Berkeley database */
|
/** RAII class that provides access to a Berkeley database */
|
||||||
|
|
Loading…
Reference in a new issue