PPCoin: Fix bug in CBlock::ReadFromDisk() since 94ced845
[novacoin.git] / src / db.cpp
index 40cc35e..d4dae8d 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
 // Copyright (c) 2011 The Bitcoin developers
-// Copyright (c) 2011 The PPCoin developers
+// Copyright (c) 2011-2012 The PPCoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
 
@@ -475,9 +475,10 @@ bool CTxDB::ReadAutoCheckpoint(int& nAutoCheckpoint)
     return Read(string("nAutoCheckpoint"), nAutoCheckpoint);
 }
 
-bool CTxDB::WriteAutoCheckpoint(int nCheckpoint)
+bool CTxDB::WriteAutoCheckpoint(int nCheckpoint, bool fReset)
 {
-    return Write(string("nAutoCheckpoint"), max(Checkpoints::nAutoCheckpoint, nCheckpoint));
+    nCheckpoint = fReset? nCheckpoint : max(Checkpoints::nAutoCheckpoint, nCheckpoint);
+    return Write(string("nAutoCheckpoint"), nCheckpoint);
 }
 
 CBlockIndex static * InsertBlockIndex(uint256 hash)
@@ -539,6 +540,8 @@ bool CTxDB::LoadBlockIndex()
             pindexNew->nBlockPos      = diskindex.nBlockPos;
             pindexNew->nChainTrust    = diskindex.nChainTrust;
             pindexNew->nHeight        = diskindex.nHeight;
+            pindexNew->nCheckpoint    = diskindex.nCheckpoint;
+            pindexNew->fProofOfStake  = diskindex.fProofOfStake;
             pindexNew->nVersion       = diskindex.nVersion;
             pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
             pindexNew->nTime          = diskindex.nTime;
@@ -929,6 +932,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
                 if (strKey == "fUseProxy")          ssValue >> fUseProxy;
                 if (strKey == "addrProxy")          ssValue >> addrProxy;
                 if (fHaveUPnP && strKey == "fUseUPnP")           ssValue >> fUseUPnP;
+                if (strKey == "nBalanceReserve")    ssValue >> nBalanceReserve;
             }
             else if (strType == "minversion")
             {