X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Ftxdb-leveldb.cpp;h=8f956fe16413c5c6f29a3414706fe2401265bf14;hb=2404891de8ac5b357d0abde90f2e286a3153fdef;hp=8367665b8018fc61e5684b846f4ffd50895f3f1f;hpb=bafc8da08d2a0ece54ac443aa4569974b319cccb;p=novacoin.git diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp index 8367665..8f956fe 100644 --- a/src/txdb-leveldb.cpp +++ b/src/txdb-leveldb.cpp @@ -27,7 +27,7 @@ leveldb::DB *txdb; // global pointer for LevelDB object instance static leveldb::Options GetOptions() { leveldb::Options options; - int nCacheSizeMB = GetArg("-dbcache", 25); + int nCacheSizeMB = GetArgInt("-dbcache", 25); options.block_cache = leveldb::NewLRUCache(nCacheSizeMB * 1048576); options.filter_policy = leveldb::NewBloomFilterPolicy(10); return options; @@ -41,7 +41,7 @@ void init_blockindex(leveldb::Options& options, bool fRemoveOld = false) { filesystem::remove_all(directory); // remove directory unsigned int nFile = 1; - while (true) + for ( ; ; ) { filesystem::path strBlockFile = GetDataDir() / strprintf("blk%04u.dat", nFile); @@ -304,6 +304,16 @@ bool CTxDB::WriteCheckpointPubKey(const string& strPubKey) return Write(string("strCheckpointPubKey"), strPubKey); } +bool CTxDB::ReadModifierUpgradeTime(unsigned int& nUpgradeTime) +{ + return Read(string("nUpgradeTime"), nUpgradeTime); +} + +bool CTxDB::WriteModifierUpgradeTime(const unsigned int& nUpgradeTime) +{ + return Write(string("nUpgradeTime"), nUpgradeTime); +} + static CBlockIndex *InsertBlockIndex(uint256 hash) { if (hash == 0) @@ -315,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; @@ -413,7 +423,7 @@ bool CTxDB::LoadBlockIndex() // NovaCoin: calculate stake modifier checksum pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex); if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum)) - return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindex->nHeight, pindex->nStakeModifier); + return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016" PRIx64, pindex->nHeight, pindex->nStakeModifier); } // Load hashBestChain pointer to end of best chain @@ -444,8 +454,8 @@ bool CTxDB::LoadBlockIndex() nBestInvalidTrust = bnBestInvalidTrust.getuint256(); // Verify blocks in the best chain - int nCheckLevel = GetArg("-checklevel", 1); - int nCheckDepth = GetArg( "-checkblocks", 2500); + int nCheckLevel = GetArgInt("-checklevel", 1); + int nCheckDepth = GetArgInt( "-checkblocks", 2500); if (nCheckDepth == 0) nCheckDepth = 1000000000; // suffices until the year 19000 if (nCheckDepth > nBestHeight)