DbEnv(0).remove(strPath.c_str(), 0);
}
-CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS), fDetachDB(false), fDbEnvInit(false), fMockDb(false) { }
+CDBEnv::CDBEnv() : fDetachDB(false), fDbEnvInit(false), fMockDb(false), dbenv(DB_CXX_NO_EXCEPTIONS) { }
CDBEnv::~CDBEnv()
{
return false;
pathEnv = pathEnv_;
- filesystem::path pathDataDir = pathEnv;
+ boost::filesystem::path pathDataDir = pathEnv;
strPath = pathDataDir.string();
- filesystem::path pathLogDir = pathDataDir / "database";
- filesystem::create_directory(pathLogDir);
- filesystem::path pathErrorFile = pathDataDir / "db.log";
+ boost::filesystem::path pathLogDir = pathDataDir / "database";
+ boost::filesystem::create_directory(pathLogDir);
+ boost::filesystem::path pathErrorFile = pathDataDir / "db.log";
printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str());
unsigned int nEnvFlags = 0;
nBlocks = nMaxLocks / 48768;
nDeepReorg = (nBlocks - 1) / 2;
- printf("Final lk_max_locks is %lu, sufficient for (worst case) %d block%s in a single transaction (up to a %d-deep reorganization)\n", (unsigned long)nMaxLocks, nBlocks, (nBlocks == 1) ? "" : "s", nDeepReorg);
+ printf("Final lk_max_locks is %u, sufficient for (worst case) %d block%s in a single transaction (up to a %d-deep reorganization)\n", nMaxLocks, nBlocks, (nBlocks == 1) ? "" : "s", nDeepReorg);
if (nDeepReorg < 3)
{
if (nBlocks < 1)
- strMessage = strprintf(_("Warning: DB_CONFIG has set_lk_max_locks %lu, which may be too low for a single block. If this limit is reached, NovaCoin may stop working."), (unsigned long)nMaxLocks);
+ strMessage = strprintf(_("Warning: DB_CONFIG has set_lk_max_locks %u, which may be too low for a single block. If this limit is reached, NovaCoin may stop working."), nMaxLocks);
else
- strMessage = strprintf(_("Warning: DB_CONFIG has set_lk_max_locks %lu, which may be too low for a common blockchain reorganization. If this limit is reached, NovaCoin may stop working."), (unsigned long)nMaxLocks);
+ strMessage = strprintf(_("Warning: DB_CONFIG has set_lk_max_locks %u, which may be too low for a common blockchain reorganization. If this limit is reached, NovaCoin may stop working."), nMaxLocks);
strMiscWarning = strMessage;
printf("*** %s\n", strMessage.c_str());
delete pdb;
pdb = NULL;
--bitdb.mapFileUseCount[strFile];
- strFile = "";
+ strFile.clear();
throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", pszFile, ret));
}
}
Dbc* pcursor = db.GetCursor();
- if (pcursor)
+ if (pcursor) {
while (fSuccess)
{
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
fSuccess = false;
break;
}
- if (pszSkip &&
- strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
- continue;
+
+ if (pszSkip != NULL)
+ {
+ size_t pszSkipLen = strlen(pszSkip);
+ if (strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), pszSkipLen)) == 0)
+ continue;
+ }
+
if (strncmp(&ssKey[0], "\x07version", 8) == 0)
{
// Update version:
if (ret2 > 0)
fSuccess = false;
}
+ }
if (fSuccess)
{
db.Close();