Bitcoin Core  0.15.99
P2P Digital Currency
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
BerkeleyEnvironment Class Reference

#include <db.h>

Public Types

enum  VerifyResult { VerifyResult::VERIFY_OK, VerifyResult::RECOVER_OK, VerifyResult::RECOVER_FAIL }
 Verify that database file strFile is OK. More...
 
typedef bool(* recoverFunc_type) (const fs::path &file_path, std::string &out_backup_filename)
 
typedef std::pair< std::vector< unsigned char >, std::vector< unsigned char > > KeyValPair
 Salvage data from a file that Verify says is bad. More...
 

Public Member Functions

 BerkeleyEnvironment (const fs::path &env_directory)
 
 ~BerkeleyEnvironment ()
 
void Reset ()
 
void MakeMock ()
 
bool IsMock () const
 
bool IsInitialized () const
 
bool IsDatabaseLoaded (const std::string &db_filename) const
 
fs::path Directory () const
 
VerifyResult Verify (const std::string &strFile, recoverFunc_type recoverFunc, std::string &out_backup_filename)
 
bool Salvage (const std::string &strFile, bool fAggressive, std::vector< KeyValPair > &vResult)
 
bool Open (bool retry)
 
void Close ()
 
void Flush (bool fShutdown)
 
void CheckpointLSN (const std::string &strFile)
 
void CloseDb (const std::string &strFile)
 
void ReloadDbEnv ()
 
DbTxn * TxnBegin (int flags=DB_TXN_WRITE_NOSYNC)
 

Public Attributes

std::unique_ptr< DbEnv > dbenv
 
std::map< std::string, int > mapFileUseCount
 
std::map< std::string, std::reference_wrapper< BerkeleyDatabase > > m_databases
 
std::unordered_map< std::string, WalletDatabaseFileIdm_fileids
 
std::condition_variable_any m_db_in_use
 

Private Attributes

bool fDbEnvInit
 
bool fMockDb
 
std::string strPath
 

Detailed Description

Definition at line 36 of file db.h.

Member Typedef Documentation

◆ KeyValPair

typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > BerkeleyEnvironment::KeyValPair

Salvage data from a file that Verify says is bad.

fAggressive sets the DB_AGGRESSIVE flag (see berkeley DB->verify() method documentation). Appends binary key/value pairs to vResult, returns true if successful. NOTE: reads the entire database into memory, so cannot be used for huge databases.

Definition at line 80 of file db.h.

◆ recoverFunc_type

typedef bool(* BerkeleyEnvironment::recoverFunc_type) (const fs::path &file_path, std::string &out_backup_filename)

Definition at line 71 of file db.h.

Member Enumeration Documentation

◆ VerifyResult

Verify that database file strFile is OK.

If it is not, call the callback to try to recover. This must be called BEFORE strFile is opened. Returns true if strFile is OK.

Enumerator
VERIFY_OK 
RECOVER_OK 
RECOVER_FAIL 

Definition at line 68 of file db.h.

Constructor & Destructor Documentation

◆ BerkeleyEnvironment()

BerkeleyEnvironment::BerkeleyEnvironment ( const fs::path &  env_directory)

Definition at line 133 of file db.cpp.

Here is the call graph for this function:

◆ ~BerkeleyEnvironment()

BerkeleyEnvironment::~BerkeleyEnvironment ( )

Definition at line 138 of file db.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ CheckpointLSN()

void BerkeleyEnvironment::CheckpointLSN ( const std::string &  strFile)

Definition at line 453 of file db.cpp.

Here is the caller graph for this function:

◆ Close()

void BerkeleyEnvironment::Close ( )

Definition at line 102 of file db.cpp.

Here is the caller graph for this function:

◆ CloseDb()

void BerkeleyEnvironment::CloseDb ( const std::string &  strFile)

Definition at line 578 of file db.cpp.

Here is the caller graph for this function:

◆ Directory()

fs::path BerkeleyEnvironment::Directory ( ) const
inline

Definition at line 60 of file db.h.

Here is the caller graph for this function:

◆ Flush()

void BerkeleyEnvironment::Flush ( bool  fShutdown)

Definition at line 708 of file db.cpp.

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

◆ IsDatabaseLoaded()

bool BerkeleyEnvironment::IsDatabaseLoaded ( const std::string &  db_filename) const
inline

Definition at line 59 of file db.h.

◆ IsInitialized()

bool BerkeleyEnvironment::IsInitialized ( ) const
inline

Definition at line 58 of file db.h.

◆ IsMock()

bool BerkeleyEnvironment::IsMock ( ) const
inline

Definition at line 57 of file db.h.

Here is the caller graph for this function:

◆ MakeMock()

void BerkeleyEnvironment::MakeMock ( )

Definition at line 217 of file db.cpp.

Here is the caller graph for this function:

◆ Open()

bool BerkeleyEnvironment::Open ( bool  retry)

debug

Definition at line 143 of file db.cpp.

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

◆ ReloadDbEnv()

void BerkeleyEnvironment::ReloadDbEnv ( )

Definition at line 593 of file db.cpp.

Here is the caller graph for this function:

◆ Reset()

void BerkeleyEnvironment::Reset ( )

Definition at line 126 of file db.cpp.

Here is the caller graph for this function:

◆ Salvage()

bool BerkeleyEnvironment::Salvage ( const std::string &  strFile,
bool  fAggressive,
std::vector< KeyValPair > &  vResult 
)

Definition at line 392 of file db.cpp.

◆ TxnBegin()

DbTxn* BerkeleyEnvironment::TxnBegin ( int  flags = DB_TXN_WRITE_NOSYNC)
inline

Definition at line 91 of file db.h.

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

◆ Verify()

BerkeleyEnvironment::VerifyResult BerkeleyEnvironment::Verify ( const std::string &  strFile,
recoverFunc_type  recoverFunc,
std::string &  out_backup_filename 
)

Definition at line 249 of file db.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ dbenv

std::unique_ptr<DbEnv> BerkeleyEnvironment::dbenv

Definition at line 46 of file db.h.

◆ fDbEnvInit

bool BerkeleyEnvironment::fDbEnvInit
private

Definition at line 39 of file db.h.

◆ fMockDb

bool BerkeleyEnvironment::fMockDb
private

Definition at line 40 of file db.h.

◆ m_databases

std::map<std::string, std::reference_wrapper<BerkeleyDatabase> > BerkeleyEnvironment::m_databases

Definition at line 48 of file db.h.

◆ m_db_in_use

std::condition_variable_any BerkeleyEnvironment::m_db_in_use

Definition at line 50 of file db.h.

◆ m_fileids

std::unordered_map<std::string, WalletDatabaseFileId> BerkeleyEnvironment::m_fileids

Definition at line 49 of file db.h.

◆ mapFileUseCount

std::map<std::string, int> BerkeleyEnvironment::mapFileUseCount

Definition at line 47 of file db.h.

◆ strPath

std::string BerkeleyEnvironment::strPath
private

Definition at line 43 of file db.h.


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