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
 
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)
 
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
 

Private Attributes

bool fDbEnvInit
 
bool fMockDb
 
std::string strPath
 

Detailed Description

Definition at line 28 of file db.h.

Member Typedef Documentation

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

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

Definition at line 60 of file db.h.

Member Enumeration Documentation

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

Constructor & Destructor Documentation

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 ( )

Definition at line 122 of file db.cpp.

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 433 of file db.cpp.

Here is the caller graph for this function:

void BerkeleyEnvironment::Close ( )

Definition at line 86 of file db.cpp.

Here is the caller graph for this function:

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

Definition at line 557 of file db.cpp.

Here is the caller graph for this function:

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

Definition at line 49 of file db.h.

Here is the caller graph for this function:

void BerkeleyEnvironment::Flush ( bool  fShutdown)

Definition at line 660 of file db.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool BerkeleyEnvironment::IsInitialized ( ) const
inline

Definition at line 48 of file db.h.

bool BerkeleyEnvironment::IsMock ( ) const
inline

Definition at line 47 of file db.h.

Here is the caller graph for this function:

void BerkeleyEnvironment::MakeMock ( )

Definition at line 197 of file db.cpp.

Here is the caller graph for this function:

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:

void BerkeleyEnvironment::Reset ( )

Definition at line 110 of file db.cpp.

Here is the caller graph for this function:

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

Definition at line 372 of file db.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 79 of file db.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 229 of file db.cpp.

Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<DbEnv> BerkeleyEnvironment::dbenv

Definition at line 38 of file db.h.

bool BerkeleyEnvironment::fDbEnvInit
private

Definition at line 31 of file db.h.

bool BerkeleyEnvironment::fMockDb
private

Definition at line 32 of file db.h.

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

Definition at line 40 of file db.h.

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

Definition at line 39 of file db.h.

std::string BerkeleyEnvironment::strPath
private

Definition at line 35 of file db.h.


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