Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
BerkeleyDatabase Class Reference

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

#include <bdb.h>

Inheritance diagram for BerkeleyDatabase:
[legend]
Collaboration diagram for BerkeleyDatabase:
[legend]

Public Member Functions

 BerkeleyDatabase ()=delete
 
 BerkeleyDatabase (std::shared_ptr< BerkeleyEnvironment > envIn, std::string filename)
 Create DB handle to real database.
 
 ~BerkeleyDatabase () override
 
void Open () override
 Open the database if it is not already opened.
 
bool Rewrite (const char *pszSkip=nullptr) override
 Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
 
void AddRef () override
 Indicate the a new database user has began using the database.
 
void RemoveRef () override
 Indicate that database user has stopped using the database and that it could be flushed or closed.
 
bool Backup (const std::string &strDest) const override
 Back up the entire database to a file.
 
void Flush () override
 Make sure all changes are flushed to database file.
 
void Close () override
 Flush to the database file and close the database.
 
bool PeriodicFlush () override
 flush the wallet passively (TRY_LOCK) ideal to be called periodically
 
void IncrementUpdateCounter () override
 
void ReloadDbEnv () override
 
bool Verify (bilingual_str &error)
 Verifies the environment and database file.
 
std::string Filename () override
 Return path to main database filename.
 
std::unique_ptr< DatabaseBatchMakeBatch (bool flush_on_close=true) override
 Make a BerkeleyBatch connected to this database.
 
- Public Member Functions inherited from WalletDatabase
 WalletDatabase ()
 Create dummy DB handle.
 
virtual ~WalletDatabase ()
 

Public Attributes

std::shared_ptr< BerkeleyEnvironmentenv
 Pointer to shared database environment.
 
std::unique_ptr< Dbm_db
 Database pointer.
 
std::string strFile
 
- Public Attributes inherited from WalletDatabase
std::atomic< intm_refcount {0}
 Counts the number of active database users to be sure that the database is not closed while someone is using it.
 
std::atomic< unsigned intnUpdateCounter
 
unsigned int nLastSeen
 
unsigned int nLastFlushed
 
int64_t nLastWalletUpdate
 

Detailed Description

An instance of this class represents one database.

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

Definition at line 94 of file bdb.h.

Constructor & Destructor Documentation

◆ BerkeleyDatabase() [1/2]

BerkeleyDatabase::BerkeleyDatabase ( )
delete

◆ BerkeleyDatabase() [2/2]

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

Create DB handle to real database.

Definition at line 99 of file bdb.h.

Here is the call graph for this function:

◆ ~BerkeleyDatabase()

BerkeleyDatabase::~BerkeleyDatabase ( )
override

Definition at line 322 of file bdb.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ AddRef()

void BerkeleyDatabase::AddRef ( )
overridevirtual

Indicate the a new database user has began using the database.

Implements WalletDatabase.

Definition at line 878 of file bdb.cpp.

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

◆ Backup()

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

Back up the entire database to a file.

Implements WalletDatabase.

Definition at line 685 of file bdb.cpp.

Here is the call graph for this function:

◆ Close()

void BerkeleyDatabase::Close ( )
overridevirtual

Flush to the database file and close the database.

Also close the environment if no other databases are open in it.

Implements WalletDatabase.

Definition at line 730 of file bdb.cpp.

◆ Filename()

std::string BerkeleyDatabase::Filename ( )
inlineoverridevirtual

Return path to main database filename.

Implements WalletDatabase.

Definition at line 158 of file bdb.h.

Here is the call graph for this function:

◆ Flush()

void BerkeleyDatabase::Flush ( )
overridevirtual

Make sure all changes are flushed to database file.

Implements WalletDatabase.

Definition at line 726 of file bdb.cpp.

◆ IncrementUpdateCounter()

void BerkeleyDatabase::IncrementUpdateCounter ( )
overridevirtual

Implements WalletDatabase.

Definition at line 427 of file bdb.cpp.

◆ MakeBatch()

std::unique_ptr< DatabaseBatch > BerkeleyDatabase::MakeBatch ( bool  flush_on_close = true)
overridevirtual

Make a BerkeleyBatch connected to this database.

Implements WalletDatabase.

Definition at line 896 of file bdb.cpp.

Here is the call graph for this function:

◆ Open()

void BerkeleyDatabase::Open ( )
overridevirtual

Open the database if it is not already opened.

Implements WalletDatabase.

Definition at line 352 of file bdb.cpp.

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

◆ PeriodicFlush()

bool BerkeleyDatabase::PeriodicFlush ( )
overridevirtual

flush the wallet passively (TRY_LOCK) ideal to be called periodically

Implements WalletDatabase.

Definition at line 652 of file bdb.cpp.

Here is the call graph for this function:

◆ ReloadDbEnv()

void BerkeleyDatabase::ReloadDbEnv ( )
overridevirtual

Implements WalletDatabase.

Definition at line 734 of file bdb.cpp.

◆ RemoveRef()

void BerkeleyDatabase::RemoveRef ( )
overridevirtual

Indicate that database user has stopped using the database and that it could be flushed or closed.

Implements WalletDatabase.

Definition at line 887 of file bdb.cpp.

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

◆ Rewrite()

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

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

Implements WalletDatabase.

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

Here is the call graph for this function:

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

◆ strFile

std::string BerkeleyDatabase::strFile

Definition at line 179 of file bdb.h.


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