Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/db.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_WALLET_DB_H | #ifndef BITCOIN_WALLET_DB_H | ||||
#define BITCOIN_WALLET_DB_H | #define BITCOIN_WALLET_DB_H | ||||
#include "clientversion.h" | #include "clientversion.h" | ||||
#include "fs.h" | |||||
#include "serialize.h" | #include "serialize.h" | ||||
#include "streams.h" | #include "streams.h" | ||||
#include "sync.h" | #include "sync.h" | ||||
#include "version.h" | #include "version.h" | ||||
#include <map> | #include <map> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
#include <boost/filesystem/path.hpp> | |||||
#include <db_cxx.h> | #include <db_cxx.h> | ||||
static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100; | static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100; | ||||
static const bool DEFAULT_WALLET_PRIVDB = true; | static const bool DEFAULT_WALLET_PRIVDB = true; | ||||
class CDBEnv { | class CDBEnv { | ||||
private: | private: | ||||
bool fDbEnvInit; | bool fDbEnvInit; | ||||
bool fMockDb; | bool fMockDb; | ||||
// Don't change into boost::filesystem::path, as that can result in | // Don't change into fs::path, as that can result in | ||||
// shutdown problems/crashes caused by a static initialized internal | // shutdown problems/crashes caused by a static initialized internal | ||||
// pointer. | // pointer. | ||||
std::string strPath; | std::string strPath; | ||||
void EnvShutdown(); | void EnvShutdown(); | ||||
public: | public: | ||||
mutable CCriticalSection cs_db; | mutable CCriticalSection cs_db; | ||||
Show All 25 Lines | public: | ||||
* Appends binary key/value pairs to vResult, returns true if successful. | * Appends binary key/value pairs to vResult, returns true if successful. | ||||
* NOTE: reads the entire database into memory, so cannot be used | * NOTE: reads the entire database into memory, so cannot be used | ||||
* for huge databases. | * for huge databases. | ||||
*/ | */ | ||||
typedef std::pair<std::vector<uint8_t>, std::vector<uint8_t>> KeyValPair; | typedef std::pair<std::vector<uint8_t>, std::vector<uint8_t>> KeyValPair; | ||||
bool Salvage(const std::string &strFile, bool fAggressive, | bool Salvage(const std::string &strFile, bool fAggressive, | ||||
std::vector<KeyValPair> &vResult); | std::vector<KeyValPair> &vResult); | ||||
bool Open(const boost::filesystem::path &path); | bool Open(const fs::path &path); | ||||
void Close(); | void Close(); | ||||
void Flush(bool fShutdown); | void Flush(bool fShutdown); | ||||
void CheckpointLSN(const std::string &strFile); | void CheckpointLSN(const std::string &strFile); | ||||
void CloseDb(const std::string &strFile); | void CloseDb(const std::string &strFile); | ||||
bool RemoveDb(const std::string &strFile); | bool RemoveDb(const std::string &strFile); | ||||
DbTxn *TxnBegin(int flags = DB_TXN_WRITE_NOSYNC) { | DbTxn *TxnBegin(int flags = DB_TXN_WRITE_NOSYNC) { | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |