X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Ftxdb-bdb.cpp;h=1235125c821d95d1c35d08de4d3d50eade13f33c;hb=cecf7a56ed5a5efd939b21c760c69da616306005;hp=41883d05575f659387ab35d48fca6586001a60f0;hpb=adb8391acdf671640adb1e8be564e68b254fca69;p=novacoin.git diff --git a/src/txdb-bdb.cpp b/src/txdb-bdb.cpp index 41883d0..1235125 100644 --- a/src/txdb-bdb.cpp +++ b/src/txdb-bdb.cpp @@ -139,6 +139,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); +} + CBlockIndex static * InsertBlockIndex(uint256 hash) { if (hash == 0) @@ -150,7 +160,7 @@ CBlockIndex static * 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; @@ -183,7 +193,7 @@ bool CTxDB::LoadBlockIndex() // ppcoin: 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 @@ -213,8 +223,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) @@ -352,7 +362,7 @@ bool CTxDB::LoadBlockIndexGuts() // Load mapBlockIndex unsigned int fFlags = DB_SET_RANGE; - while (true) + for ( ; ; ) { // Read next record CDataStream ssKey(SER_DISK, CLIENT_VERSION); @@ -376,8 +386,10 @@ bool CTxDB::LoadBlockIndexGuts() CDiskBlockIndex diskindex; ssValue >> diskindex; + uint256 blockHash = diskindex.GetBlockHash(); + // Construct block index object - CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash()); + CBlockIndex* pindexNew = InsertBlockIndex(blockHash); pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev); pindexNew->pnext = InsertBlockIndex(diskindex.hashNext); pindexNew->nFile = diskindex.nFile; @@ -397,7 +409,7 @@ bool CTxDB::LoadBlockIndexGuts() pindexNew->nNonce = diskindex.nNonce; // Watch for genesis block - if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) + if (pindexGenesisBlock == NULL && blockHash == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) pindexGenesisBlock = pindexNew; if (!pindexNew->CheckIndex()) @@ -412,8 +424,8 @@ bool CTxDB::LoadBlockIndexGuts() break; // if shutdown requested or finished loading block index } } // try - catch (std::exception &e) { - return error("%s() : deserialize error", __PRETTY_FUNCTION__); + catch (const std::exception&) { + return error("%s() : deserialize error", BOOST_CURRENT_FUNCTION); } } pcursor->close();