Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Go to the documentation of this file. 5 #ifndef FLAT_DATABASE_H 6 #define FLAT_DATABASE_H 57 return error(
"%s: Failed to open file %s", __func__,
pathDB.string());
63 catch (std::exception &e) {
64 return error(
"%s: Serialize or I/O error - %s", __func__, e.what());
84 error(
"%s: Failed to open file %s", __func__,
pathDB.string());
89 int fileSize = fs::file_size(
pathDB);
90 int dataSize = fileSize -
sizeof(
uint256);
94 std::vector<unsigned char> vchData;
95 vchData.resize(dataSize);
100 filein.read((
char *)vchData.data(), dataSize);
103 catch (std::exception &e) {
104 error(
"%s: Deserialize or I/O error - %s", __func__, e.what());
113 if (hashIn != hashTmp)
115 error(
"%s: Checksum mismatch, data corrupted", __func__);
120 unsigned char pchMsgTmp[4];
121 std::string strMagicMessageTmp;
124 ssObj >> strMagicMessageTmp;
129 error(
"%s: Invalid magic message", __func__);
138 if (memcmp(pchMsgTmp,
Params().MessageStart(),
sizeof(pchMsgTmp)))
140 error(
"%s: Invalid network magic number", __func__);
147 catch (std::exception &e) {
149 error(
"%s: Deserialize or I/O error - %s", __func__, e.what());
154 LogPrintf(
" %s\n", objToLoad.ToString());
156 LogPrintf(
"%s: Cleaning....\n", __func__);
157 objToLoad.CheckAndRemove();
158 LogPrintf(
" %s\n", objToLoad.ToString());
166 CFlatDB(std::string strFilenameIn, std::string strMagicMessageIn)
179 else if (readResult !=
Ok)
184 LogPrintf(
"%s: Magic is ok but data has invalid format, will try to recreate\n", __func__);
187 LogPrintf(
"%s: File format is unknown or invalid, please fix it manually\n", __func__);
206 else if (readResult !=
Ok)
210 LogPrintf(
"%s: Magic is ok but data has invalid format, will try to recreate\n", __func__);
213 LogPrintf(
"%s: File format is unknown or invalid, please fix it manually\n", __func__);
bool Write(const T &objToSave)
ReadResult Read(T &objToLoad, bool fDryRun=false)
FILE * fopen(const fs::path &p, const char *mode)
static FILE * fileout
We use boost::call_once() to make sure mutexDebugLog and vMsgsBeforeOpenLog are initialized in a thre...
Double ended buffer combining vector and stream-like interfaces.
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
std::string strMagicMessage
CFlatDB(std::string strFilenameIn, std::string strMagicMessageIn)
const_iterator end() const
const_iterator begin() const
Generic Dumping and Loading
const CChainParams & Params()
Return the currently selected parameters.
int64_t GetTimeMillis()
Returns the system time (not mockable)
bool error(const char *fmt, const Args &... args)
const fs::path & GetDataDir(bool fNetSpecific)
static const int CLIENT_VERSION
dashd-res.rc includes this file, but it cannot cope with real c++ code.
Non-refcounted RAII wrapper for FILE*.