X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Ftxdb-leveldb.cpp;h=f68c53783d0f9eced3ecced260105c3deacac7eb;hb=9db337843422fcc97df8e3747a9828f6dc2395b5;hp=4a7a3cfcee45d70970ee8d5e907ef22f30a65fab;hpb=fe326c477b0b109819653dc2657495f867ff8616;p=novacoin.git diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp index 4a7a3cf..f68c537 100644 --- a/src/txdb-leveldb.cpp +++ b/src/txdb-leveldb.cpp @@ -16,7 +16,7 @@ #include "kernel.h" #include "checkpoints.h" -#include "txdb.h" +#include "txdb-leveldb.h" #include "util.h" #include "main.h" @@ -35,27 +35,27 @@ static leveldb::Options GetOptions() { void init_blockindex(leveldb::Options& options, bool fRemoveOld = false) { // First time init. - filesystem::path directory = GetDataDir() / "txleveldb"; + boost::filesystem::path directory = GetDataDir() / "txleveldb"; if (fRemoveOld) { - filesystem::remove_all(directory); // remove directory + boost::filesystem::remove_all(directory); // remove directory unsigned int nFile = 1; - while (true) + for ( ; ; ) { - filesystem::path strBlockFile = GetDataDir() / strprintf("blk%04u.dat", nFile); + boost::filesystem::path strBlockFile = GetDataDir() / strprintf("blk%04u.dat", nFile); // Break if no such file - if( !filesystem::exists( strBlockFile ) ) + if( !boost::filesystem::exists( strBlockFile ) ) break; - filesystem::remove(strBlockFile); + boost::filesystem::remove(strBlockFile); nFile++; } } - filesystem::create_directory(directory); + boost::filesystem::create_directory(directory); printf("Opening LevelDB in %s\n", directory.string().c_str()); leveldb::Status status = leveldb::DB::Open(options, directory.string(), &txdb); if (!status.ok()) { @@ -64,7 +64,7 @@ void init_blockindex(leveldb::Options& options, bool fRemoveOld = false) { } // CDB subclasses are created and destroyed VERY OFTEN. That's why -// we shouldn't treat this as a free operations. +// we shouldn't treat this as free operations. CTxDB::CTxDB(const char* pszMode) { assert(pszMode); @@ -325,7 +325,7 @@ static CBlockIndex *InsertBlockIndex(uint256 hash) return (*mi).second; // Create new - CBlockIndex* pindexNew = new CBlockIndex(); + CBlockIndex* pindexNew = new(nothrow) CBlockIndex(); if (!pindexNew) throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;