Bitcoin Core  0.20.99
P2P Digital Currency
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 <bdb.h>

Public Member Functions

 BerkeleyDatabase ()
 Create dummy DB handle. More...
 
 BerkeleyDatabase (std::shared_ptr< BerkeleyEnvironment > env, std::string filename)
 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) const
 Back up the entire database to a file. More...
 
void Flush (bool shutdown)
 Make sure all changes are flushed to disk. More...
 
bool PeriodicFlush ()
 
void IncrementUpdateCounter ()
 
void ReloadDbEnv ()
 
bool Verify (bilingual_str &error)
 Verifies the environment and database file. More...
 

Public Attributes

std::atomic< unsigned int > nUpdateCounter
 
unsigned int nLastSeen
 
unsigned int nLastFlushed
 
int64_t nLastWalletUpdate
 
std::shared_ptr< BerkeleyEnvironmentenv
 Pointer to shared database environment. More...
 
std::unique_ptr< Db > m_db
 Database pointer. More...
 

Private Member Functions

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

Private Attributes

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 99 of file bdb.h.

Constructor & Destructor Documentation

◆ BerkeleyDatabase() [1/2]

BerkeleyDatabase::BerkeleyDatabase ( )
inline

Create dummy DB handle.

Definition at line 104 of file bdb.h.

◆ BerkeleyDatabase() [2/2]

BerkeleyDatabase::BerkeleyDatabase ( std::shared_ptr< BerkeleyEnvironment env,
std::string  filename 
)
inline

Create DB handle to real database.

Definition at line 109 of file bdb.h.

◆ ~BerkeleyDatabase()

BerkeleyDatabase::~BerkeleyDatabase ( )
inline

Definition at line 116 of file bdb.h.

Here is the call graph for this function:

Member Function Documentation

◆ Backup()

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

Back up the entire database to a file.

Definition at line 656 of file bdb.cpp.

Here is the call graph for this function:

◆ Flush()

void BerkeleyDatabase::Flush ( bool  shutdown)

Make sure all changes are flushed to disk.

Definition at line 697 of file bdb.cpp.

Here is the call graph for this function:

◆ IncrementUpdateCounter()

void BerkeleyDatabase::IncrementUpdateCounter ( )

Definition at line 422 of file bdb.cpp.

◆ IsDummy()

bool BerkeleyDatabase::IsDummy ( ) const
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 171 of file bdb.h.

Here is the caller graph for this function:

◆ PeriodicFlush()

bool BerkeleyDatabase::PeriodicFlush ( )

Definition at line 616 of file bdb.cpp.

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

◆ ReloadDbEnv()

void BerkeleyDatabase::ReloadDbEnv ( )

Definition at line 716 of file bdb.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 488 of file bdb.cpp.

Here is the call graph for this function:

◆ Verify()

bool BerkeleyDatabase::Verify ( bilingual_str error)

Verifies the environment and database file.

Definition at line 295 of file bdb.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ BerkeleyBatch

friend class BerkeleyBatch
friend

Definition at line 101 of file bdb.h.

Member Data Documentation

◆ env

std::shared_ptr<BerkeleyEnvironment> BerkeleyDatabase::env

Pointer to shared database environment.

Normally there is only one BerkeleyDatabase object per BerkeleyEnvivonment, but in the special, backwards compatible case where multiple wallet BDB data files are loaded from the same directory, this will point to a shared instance that gets freed when the last data file is closed.

Definition at line 159 of file bdb.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 162 of file bdb.h.

◆ nLastFlushed

unsigned int BerkeleyDatabase::nLastFlushed

Definition at line 144 of file bdb.h.

◆ nLastSeen

unsigned int BerkeleyDatabase::nLastSeen

Definition at line 143 of file bdb.h.

◆ nLastWalletUpdate

int64_t BerkeleyDatabase::nLastWalletUpdate

Definition at line 145 of file bdb.h.

◆ nUpdateCounter

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

Definition at line 142 of file bdb.h.

◆ strFile

std::string BerkeleyDatabase::strFile
private

Definition at line 165 of file bdb.h.


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