Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | List of all members
wallet::BerkeleyDatabase Class Reference

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

#include <bdb.h>

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

Public Member Functions

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

Public Attributes

std::shared_ptr< BerkeleyEnvironmentenv
 Pointer to shared database environment. More...
 
std::unique_ptr< Db > m_db
 Database pointer. More...
 
bool m_byteswap
 
fs::path m_filename
 
int64_t m_max_log_mb
 
- Public Attributes inherited from wallet::WalletDatabase
std::atomic< int > m_refcount {0}
 Counts the number of active database users to be sure that the database is not closed while someone is using it. More...
 
std::atomic< unsigned int > nUpdateCounter
 
unsigned int nLastSeen {0}
 
unsigned int nLastFlushed {0}
 
int64_t nLastWalletUpdate {0}
 

Detailed Description

An instance of this class represents one database.

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

Definition at line 88 of file bdb.h.

Constructor & Destructor Documentation

◆ BerkeleyDatabase() [1/2]

wallet::BerkeleyDatabase::BerkeleyDatabase ( )
delete

◆ BerkeleyDatabase() [2/2]

wallet::BerkeleyDatabase::BerkeleyDatabase ( std::shared_ptr< BerkeleyEnvironment env,
fs::path  filename,
const DatabaseOptions options 
)

Create DB handle to real database.

Definition at line 304 of file bdb.cpp.

Here is the call graph for this function:

◆ ~BerkeleyDatabase()

wallet::BerkeleyDatabase::~BerkeleyDatabase ( )
override

Definition at line 351 of file bdb.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ AddRef()

void wallet::BerkeleyDatabase::AddRef ( )
overridevirtual

Indicate that a new database user has begun using the database.

Implements wallet::WalletDatabase.

Definition at line 926 of file bdb.cpp.

Here is the caller graph for this function:

◆ Backup()

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

Back up the entire database to a file.

Implements wallet::WalletDatabase.

Definition at line 676 of file bdb.cpp.

Here is the call graph for this function:

◆ Close()

void wallet::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 wallet::WalletDatabase.

Definition at line 719 of file bdb.cpp.

◆ Filename()

std::string wallet::BerkeleyDatabase::Filename ( )
inlineoverridevirtual

Return path to main database filename.

Implements wallet::WalletDatabase.

Definition at line 133 of file bdb.h.

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

◆ Flush()

void wallet::BerkeleyDatabase::Flush ( )
overridevirtual

Make sure all changes are flushed to database file.

Implements wallet::WalletDatabase.

Definition at line 714 of file bdb.cpp.

◆ Format()

std::string wallet::BerkeleyDatabase::Format ( )
inlineoverridevirtual

Implements wallet::WalletDatabase.

Definition at line 135 of file bdb.h.

◆ IncrementUpdateCounter()

void wallet::BerkeleyDatabase::IncrementUpdateCounter ( )
overridevirtual

Implements wallet::WalletDatabase.

Definition at line 439 of file bdb.cpp.

◆ MakeBatch()

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

Make a BerkeleyBatch connected to this database.

Implements wallet::WalletDatabase.

Definition at line 943 of file bdb.cpp.

◆ Open()

void wallet::BerkeleyDatabase::Open ( )
overridevirtual

Open the database if it is not already opened.

Implements wallet::WalletDatabase.

Definition at line 374 of file bdb.cpp.

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

◆ PeriodicFlush()

bool wallet::BerkeleyDatabase::PeriodicFlush ( )
overridevirtual

Implements wallet::WalletDatabase.

Definition at line 648 of file bdb.cpp.

Here is the call graph for this function:

◆ ReloadDbEnv()

void wallet::BerkeleyDatabase::ReloadDbEnv ( )
overridevirtual

Implements wallet::WalletDatabase.

Definition at line 724 of file bdb.cpp.

◆ RemoveRef()

void wallet::BerkeleyDatabase::RemoveRef ( )
overridevirtual

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

Implements wallet::WalletDatabase.

Definition at line 936 of file bdb.cpp.

Here is the caller graph for this function:

◆ Rewrite()

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

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

Implements wallet::WalletDatabase.

Definition at line 515 of file bdb.cpp.

Here is the call graph for this function:

◆ Verify()

bool wallet::BerkeleyDatabase::Verify ( bilingual_str error)

Verifies the environment and database file.

Definition at line 315 of file bdb.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ env

std::shared_ptr<BerkeleyEnvironment> wallet::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 145 of file bdb.h.

◆ m_byteswap

bool wallet::BerkeleyDatabase::m_byteswap

Definition at line 151 of file bdb.h.

◆ m_db

std::unique_ptr<Db> wallet::BerkeleyDatabase::m_db

Database pointer.

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

Definition at line 148 of file bdb.h.

◆ m_filename

fs::path wallet::BerkeleyDatabase::m_filename

Definition at line 153 of file bdb.h.

◆ m_max_log_mb

int64_t wallet::BerkeleyDatabase::m_max_log_mb

Definition at line 154 of file bdb.h.


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