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

A WalletDatabase whose contents and return values can be modified as needed for testing. More...

#include <util.h>

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

Public Member Functions

 MockableDatabase (MockableData records={})
 
 ~MockableDatabase ()=default
 
void Open () override
 Open the database if it is not already opened. More...
 
void AddRef () override
 Indicate the a new database user has began 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 Rewrite (const char *pszSkip=nullptr) override
 Rewrite the entire database on disk, with the exception of key pszSkip if non-zero. 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
 
std::string Filename () override
 Return path to main database file for logs and error messages. More...
 
std::string Format () override
 
std::unique_ptr< DatabaseBatchMakeBatch (bool flush_on_close=true) override
 Make a DatabaseBatch 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

MockableData m_records
 
bool m_pass {true}
 
- 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

A WalletDatabase whose contents and return values can be modified as needed for testing.

Definition at line 103 of file util.h.

Constructor & Destructor Documentation

◆ MockableDatabase()

wallet::MockableDatabase::MockableDatabase ( MockableData  records = {})
inline

Definition at line 109 of file util.h.

◆ ~MockableDatabase()

wallet::MockableDatabase::~MockableDatabase ( )
default

Member Function Documentation

◆ AddRef()

void wallet::MockableDatabase::AddRef ( )
inlineoverridevirtual

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

Increments m_refcount

Implements wallet::WalletDatabase.

Definition at line 113 of file util.h.

◆ Backup()

bool wallet::MockableDatabase::Backup ( const std::string &  strDest) const
inlineoverridevirtual

Back up the entire database to a file.

Implements wallet::WalletDatabase.

Definition at line 117 of file util.h.

◆ Close()

void wallet::MockableDatabase::Close ( )
inlineoverridevirtual

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 119 of file util.h.

◆ Filename()

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

Return path to main database file for logs and error messages.

Implements wallet::WalletDatabase.

Definition at line 124 of file util.h.

◆ Flush()

void wallet::MockableDatabase::Flush ( )
inlineoverridevirtual

Make sure all changes are flushed to database file.

Implements wallet::WalletDatabase.

Definition at line 118 of file util.h.

◆ Format()

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

Implements wallet::WalletDatabase.

Definition at line 125 of file util.h.

◆ IncrementUpdateCounter()

void wallet::MockableDatabase::IncrementUpdateCounter ( )
inlineoverridevirtual

Implements wallet::WalletDatabase.

Definition at line 121 of file util.h.

◆ MakeBatch()

std::unique_ptr< DatabaseBatch > wallet::MockableDatabase::MakeBatch ( bool  flush_on_close = true)
inlineoverridevirtual

Make a DatabaseBatch connected to this database.

Implements wallet::WalletDatabase.

Definition at line 126 of file util.h.

◆ Open()

void wallet::MockableDatabase::Open ( )
inlineoverridevirtual

Open the database if it is not already opened.

Implements wallet::WalletDatabase.

Definition at line 112 of file util.h.

◆ PeriodicFlush()

bool wallet::MockableDatabase::PeriodicFlush ( )
inlineoverridevirtual

Implements wallet::WalletDatabase.

Definition at line 120 of file util.h.

◆ ReloadDbEnv()

void wallet::MockableDatabase::ReloadDbEnv ( )
inlineoverridevirtual

Implements wallet::WalletDatabase.

Definition at line 122 of file util.h.

◆ RemoveRef()

void wallet::MockableDatabase::RemoveRef ( )
inlineoverridevirtual

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

Decrement m_refcount

Implements wallet::WalletDatabase.

Definition at line 114 of file util.h.

◆ Rewrite()

bool wallet::MockableDatabase::Rewrite ( const char *  pszSkip = nullptr)
inlineoverridevirtual

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

Implements wallet::WalletDatabase.

Definition at line 116 of file util.h.

Member Data Documentation

◆ m_pass

bool wallet::MockableDatabase::m_pass {true}

Definition at line 107 of file util.h.

◆ m_records

MockableData wallet::MockableDatabase::m_records

Definition at line 106 of file util.h.


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