Merge pull request #353 from svost/c++11
[novacoin.git] / src / txdb-bdb.cpp
index cf2f41e..c810496 100644 (file)
 using namespace std;
 using namespace boost;
 
-void MakeMockTXDB() {
-    // In practice this won't do anything because the test framework always initializes
-    // an in-memory BDB via bitdb.MakeMock() first, as we use BDB for addresses and wallets.
-    if (!bitdb.IsMock())
-        bitdb.MakeMock();
-}
-
 //
 // CTxDB
 //
@@ -155,12 +148,12 @@ CBlockIndex static * InsertBlockIndex(uint256 hash)
         return NULL;
 
     // Return existing
-    map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
+    auto mi = mapBlockIndex.find(hash);
     if (mi != mapBlockIndex.end())
         return (*mi).second;
 
     // Create new
-    CBlockIndex* pindexNew = new(nothrow) CBlockIndex();
+    auto pindexNew = new(nothrow) CBlockIndex();
     if (!pindexNew)
         throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
     mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
@@ -182,13 +175,13 @@ bool CTxDB::LoadBlockIndex()
     vSortedByHeight.reserve(mapBlockIndex.size());
     for(const auto& item : mapBlockIndex)
     {
-        CBlockIndex* pindex = item.second;
+        auto pindex = item.second;
         vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
     }
     sort(vSortedByHeight.begin(), vSortedByHeight.end());
     for(const auto& item : vSortedByHeight)
     {
-        CBlockIndex* pindex = item.second;
+        auto pindex = item.second;
         pindex->nChainTrust = (pindex->pprev ? pindex->pprev->nChainTrust : 0) + pindex->GetBlockTrust();
         // ppcoin: calculate stake modifier checksum
         pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex);
@@ -224,7 +217,7 @@ bool CTxDB::LoadBlockIndex()
 
     // Verify blocks in the best chain
     int nCheckLevel = GetArgInt("-checklevel", 1);
-    int nCheckDepth = GetArgInt( "-checkblocks", 2500);
+    int nCheckDepth = GetArgInt( "-checkblocks", 192);
     if (nCheckDepth == 0)
         nCheckDepth = 1000000000; // suffices until the year 19000
     if (nCheckDepth > nBestHeight)
@@ -232,7 +225,7 @@ bool CTxDB::LoadBlockIndex()
     printf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
     CBlockIndex* pindexFork = NULL;
     map<pair<unsigned int, unsigned int>, CBlockIndex*> mapBlockPos;
-    for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
+    for (auto pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
     {
         if (fRequestShutdown || pindex->nHeight < nBestHeight-nCheckDepth)
             break;