Bitcoin Core  0.15.99
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
BerkeleyDatabase Class Reference

An instance of this class represents one database. More...

#include <db.h>

Collaboration diagram for BerkeleyDatabase:
[legend]

Public Member Functions

 BerkeleyDatabase ()
 Create dummy DB handle. More...
 
 BerkeleyDatabase (const fs::path &wallet_path, bool mock=false)
 Create DB handle to real database. More...
 
 ~BerkeleyDatabase ()
 
bool Rewrite (const char *pszSkip=nullptr)
 Rewrite the entire database on disk, with the exception of key pszSkip if non-zero. More...
 
bool Backup (const std::string &strDest)
 Back up the entire database to a file. More...
 
void Flush (bool shutdown)
 Make sure all changes are flushed to disk. More...
 
void IncrementUpdateCounter ()
 
void ReloadDbEnv ()
 

Static Public Member Functions

static std::unique_ptr< BerkeleyDatabaseCreate (const fs::path &path)
 Return object for accessing database at specified path. More...
 
static std::unique_ptr< BerkeleyDatabaseCreateDummy ()
 Return object for accessing dummy database with no read/write capabilities. More...
 
static std::unique_ptr< BerkeleyDatabaseCreateMock ()
 Return object for accessing temporary in-memory database. More...
 

Public Attributes

std::atomic< unsigned int > nUpdateCounter
 
unsigned int nLastSeen
 
unsigned int nLastFlushed
 
int64_t nLastWalletUpdate
 
std::unique_ptr< Db > m_db
 Database pointer. More...
 

Private Member Functions

bool IsDummy ()
 Return whether this database handle is a dummy for testing. More...
 

Private Attributes

BerkeleyEnvironmentenv
 BerkeleyDB specific. More...
 
std::string strFile
 

Friends

class BerkeleyBatch
 

Detailed Description

An instance of this class represents one database.

For BerkeleyDB this is just a (env, strFile) tuple.

Definition at line 110 of file db.h.

Constructor & Destructor Documentation

◆ BerkeleyDatabase() [1/2]

BerkeleyDatabase::BerkeleyDatabase ( )
inline

Create dummy DB handle.

Definition at line 115 of file db.h.

◆ BerkeleyDatabase() [2/2]

BerkeleyDatabase::BerkeleyDatabase ( const fs::path &  wallet_path,
bool  mock = false 
)
inline

Create DB handle to real database.

Definition at line 120 of file db.h.

Here is the call graph for this function:

◆ ~BerkeleyDatabase()

BerkeleyDatabase::~BerkeleyDatabase ( )
inline

Definition at line 133 of file db.h.

Member Function Documentation

◆ Backup()

bool BerkeleyDatabase::Backup ( const std::string &  strDest)

Back up the entire database to a file.

Definition at line 797 of file db.cpp.

Here is the call graph for this function:

◆ Create()

static std::unique_ptr<BerkeleyDatabase> BerkeleyDatabase::Create ( const fs::path &  path)
inlinestatic

Return object for accessing database at specified path.

Definition at line 141 of file db.h.

Here is the caller graph for this function:

◆ CreateDummy()

static std::unique_ptr<BerkeleyDatabase> BerkeleyDatabase::CreateDummy ( )
inlinestatic

Return object for accessing dummy database with no read/write capabilities.

Definition at line 147 of file db.h.

Here is the caller graph for this function:

◆ CreateMock()

static std::unique_ptr<BerkeleyDatabase> BerkeleyDatabase::CreateMock ( )
inlinestatic

Return object for accessing temporary in-memory database.

Definition at line 153 of file db.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Flush()

void BerkeleyDatabase::Flush ( bool  shutdown)

Make sure all changes are flushed to disk.

Definition at line 838 of file db.cpp.

Here is the call graph for this function:

◆ IncrementUpdateCounter()

void BerkeleyDatabase::IncrementUpdateCounter ( )

Definition at line 554 of file db.cpp.

◆ IsDummy()

bool BerkeleyDatabase::IsDummy ( )
inlineprivate

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.

Definition at line 191 of file db.h.

Here is the caller graph for this function:

◆ ReloadDbEnv()

void BerkeleyDatabase::ReloadDbEnv ( )

Definition at line 857 of file db.cpp.

Here is the call graph for this function:

◆ Rewrite()

bool BerkeleyDatabase::Rewrite ( const char *  pszSkip = nullptr)

Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.

Definition at line 792 of file db.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ BerkeleyBatch

friend class BerkeleyBatch
friend

Definition at line 112 of file db.h.

Member Data Documentation

◆ env

BerkeleyEnvironment* BerkeleyDatabase::env
private

BerkeleyDB specific.

Definition at line 184 of file db.h.

◆ m_db

std::unique_ptr<Db> BerkeleyDatabase::m_db

Database pointer.

This is initialized lazily and reset during flushes, so it can be null.

Definition at line 180 of file db.h.

◆ nLastFlushed

unsigned int BerkeleyDatabase::nLastFlushed

Definition at line 176 of file db.h.

◆ nLastSeen

unsigned int BerkeleyDatabase::nLastSeen

Definition at line 175 of file db.h.

◆ nLastWalletUpdate

int64_t BerkeleyDatabase::nLastWalletUpdate

Definition at line 177 of file db.h.

◆ nUpdateCounter

std::atomic<unsigned int> BerkeleyDatabase::nUpdateCounter

Definition at line 174 of file db.h.

◆ strFile

std::string BerkeleyDatabase::strFile
private

Definition at line 185 of file db.h.


The documentation for this class was generated from the following files: