BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
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
 
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, Db * > mapDb
 
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 34 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 77 of file db.h.

◆ recoverFunc_type

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

Definition at line 68 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 65 of file db.h.

Constructor & Destructor Documentation

◆ BerkeleyEnvironment()

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

Definition at line 117 of file db.cpp.

Here is the call graph for this function:

◆ ~BerkeleyEnvironment()

BerkeleyEnvironment::~BerkeleyEnvironment ( )

Definition at line 122 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 437 of file db.cpp.

Here is the caller graph for this function:

◆ Close()

void BerkeleyEnvironment::Close ( )

Definition at line 86 of file db.cpp.

Here is the caller graph for this function:

◆ CloseDb()

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

Definition at line 562 of file db.cpp.

Here is the caller graph for this function:

◆ Directory()

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

Definition at line 57 of file db.h.

Here is the caller graph for this function:

◆ Flush()

void BerkeleyEnvironment::Flush ( bool  fShutdown)

Definition at line 691 of file db.cpp.

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

◆ IsInitialized()

bool BerkeleyEnvironment::IsInitialized ( ) const
inline

Definition at line 56 of file db.h.

◆ IsMock()

bool BerkeleyEnvironment::IsMock ( ) const
inline

Definition at line 55 of file db.h.

Here is the caller graph for this function:

◆ MakeMock()

void BerkeleyEnvironment::MakeMock ( )

Definition at line 201 of file db.cpp.

Here is the caller graph for this function:

◆ Open()

bool BerkeleyEnvironment::Open ( bool  retry)

debug

Definition at line 127 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 576 of file db.cpp.

Here is the caller graph for this function:

◆ Reset()

void BerkeleyEnvironment::Reset ( )

Definition at line 110 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 376 of file db.cpp.

◆ TxnBegin()

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

Definition at line 88 of file db.h.

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 233 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 44 of file db.h.

◆ fDbEnvInit

bool BerkeleyEnvironment::fDbEnvInit
private

Definition at line 37 of file db.h.

◆ fMockDb

bool BerkeleyEnvironment::fMockDb
private

Definition at line 38 of file db.h.

◆ m_db_in_use

std::condition_variable_any BerkeleyEnvironment::m_db_in_use

Definition at line 48 of file db.h.

◆ m_fileids

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

Definition at line 47 of file db.h.

◆ mapDb

std::map<std::string, Db*> BerkeleyEnvironment::mapDb

Definition at line 46 of file db.h.

◆ mapFileUseCount

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

Definition at line 45 of file db.h.

◆ strPath

std::string BerkeleyEnvironment::strPath
private

Definition at line 41 of file db.h.


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