Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

#include <db.h>

Public Types

enum  VerifyResult { VERIFY_OK, RECOVER_OK, 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

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

◆ recoverFunc_type

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

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

Constructor & Destructor Documentation

◆ BerkeleyEnvironment()

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

Definition at line 118 of file db.cpp.

References Reset().

◆ ~BerkeleyEnvironment()

BerkeleyEnvironment::~BerkeleyEnvironment ( )

Definition at line 123 of file db.cpp.

References Close().

Member Function Documentation

◆ CheckpointLSN()

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

Definition at line 434 of file db.cpp.

References dbenv, and fMockDb.

Referenced by BerkeleyDatabase::Backup(), BerkeleyBatch::PeriodicFlush(), and BerkeleyBatch::Rewrite().

◆ Close()

void BerkeleyEnvironment::Close ( )

◆ CloseDb()

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

Definition at line 558 of file db.cpp.

References LOCK, and mapDb.

Referenced by BerkeleyDatabase::Backup(), Flush(), BerkeleyBatch::PeriodicFlush(), and BerkeleyBatch::Rewrite().

◆ Directory()

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

◆ Flush()

void BerkeleyEnvironment::Flush ( bool  fShutdown)

◆ IsInitialized()

bool BerkeleyEnvironment::IsInitialized ( ) const
inline

Definition at line 48 of file db.h.

References fDbEnvInit.

◆ IsMock()

bool BerkeleyEnvironment::IsMock ( ) const
inline

Definition at line 47 of file db.h.

References fMockDb.

Referenced by BerkeleyBatch::BerkeleyBatch().

◆ MakeMock()

void BerkeleyEnvironment::MakeMock ( )

Definition at line 198 of file db.cpp.

References BCLog::DB, dbenv, fDbEnvInit, fMockDb, LogPrint, and strprintf.

Referenced by BerkeleyDatabase::BerkeleyDatabase().

◆ Open()

◆ Reset()

void BerkeleyEnvironment::Reset ( )

Definition at line 111 of file db.cpp.

References dbenv, fDbEnvInit, and fMockDb.

Referenced by BerkeleyDatabase::BerkeleyDatabase(), and BerkeleyEnvironment().

◆ Salvage()

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

Definition at line 373 of file db.cpp.

References DATA_END, dbenv, flags, HEADER_END, LOCK, LogPrintf, mapFileUseCount, and ParseHex().

Referenced by BerkeleyBatch::Recover().

◆ TxnBegin()

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

Definition at line 79 of file db.h.

References dbenv, and flags.

Referenced by BerkeleyBatch::Recover(), and BerkeleyBatch::TxnBegin().

◆ Verify()

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

Definition at line 230 of file db.cpp.

References dbenv, LOCK, mapFileUseCount, RECOVER_FAIL, RECOVER_OK, strPath, and VERIFY_OK.

Referenced by BerkeleyBatch::VerifyDatabaseFile().

Member Data Documentation

◆ dbenv

std::unique_ptr<DbEnv> BerkeleyEnvironment::dbenv

◆ fDbEnvInit

bool BerkeleyEnvironment::fDbEnvInit
private

Definition at line 31 of file db.h.

Referenced by Close(), Flush(), IsInitialized(), MakeMock(), Open(), and Reset().

◆ fMockDb

bool BerkeleyEnvironment::fMockDb
private

Definition at line 32 of file db.h.

Referenced by CheckpointLSN(), Close(), Flush(), IsMock(), MakeMock(), Open(), and Reset().

◆ mapDb

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

Definition at line 40 of file db.h.

Referenced by BerkeleyBatch::BerkeleyBatch(), Close(), and CloseDb().

◆ mapFileUseCount

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

◆ strPath

std::string BerkeleyEnvironment::strPath
private

Definition at line 35 of file db.h.

Referenced by Close(), Directory(), Flush(), Open(), and Verify().


The documentation for this class was generated from the following files:
Released under the MIT license