Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/bdb.h
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
class BerkeleyBatch; | class BerkeleyBatch; | ||||
/** | /** | ||||
* An instance of this class represents one database. | * An instance of this class represents one database. | ||||
* For BerkeleyDB this is just a (env, strFile) tuple. | * For BerkeleyDB this is just a (env, strFile) tuple. | ||||
*/ | */ | ||||
class BerkeleyDatabase : public WalletDatabase { | class BerkeleyDatabase : public WalletDatabase { | ||||
friend class BerkeleyBatch; | |||||
public: | public: | ||||
/** Create dummy DB handle */ | /** Create dummy DB handle */ | ||||
BerkeleyDatabase() : WalletDatabase(), env(nullptr) {} | BerkeleyDatabase() : WalletDatabase(), env(nullptr) {} | ||||
/** Create DB handle to real database */ | /** Create DB handle to real database */ | ||||
BerkeleyDatabase(std::shared_ptr<BerkeleyEnvironment> envIn, | BerkeleyDatabase(std::shared_ptr<BerkeleyEnvironment> envIn, | ||||
std::string filename) | std::string filename) | ||||
: WalletDatabase(), env(std::move(envIn)), | : WalletDatabase(), env(std::move(envIn)), | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public: | ||||
std::shared_ptr<BerkeleyEnvironment> env; | std::shared_ptr<BerkeleyEnvironment> env; | ||||
/** | /** | ||||
* Database pointer. This is initialized lazily and reset during flushes, | * Database pointer. This is initialized lazily and reset during flushes, | ||||
* so it can be null. | * so it can be null. | ||||
*/ | */ | ||||
std::unique_ptr<Db> m_db; | std::unique_ptr<Db> m_db; | ||||
std::string strFile; | |||||
/** Make a BerkeleyBatch connected to this database */ | /** Make a BerkeleyBatch connected to this database */ | ||||
std::unique_ptr<DatabaseBatch> | std::unique_ptr<DatabaseBatch> | ||||
MakeBatch(const char *mode = "r+", bool flush_on_close = true) override; | MakeBatch(const char *mode = "r+", bool flush_on_close = true) override; | ||||
private: | private: | ||||
std::string strFile; | |||||
/** | /** | ||||
* Return whether this database handle is a dummy for testing. | * Return whether this database handle is a dummy for testing. | ||||
* Only to be used at a low level, application should ideally not care | * Only to be used at a low level, application should ideally not care | ||||
* about this. | * about this. | ||||
*/ | */ | ||||
bool IsDummy() const { return env == nullptr; } | bool IsDummy() const { return env == nullptr; } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |