PPCoin: Version number and rename checkpoint related constants
authorScott Nadal <scott.nadal@gmail.com>
Tue, 10 Jul 2012 15:08:27 +0000 (16:08 +0100)
committerScott Nadal <scott.nadal@gmail.com>
Tue, 10 Jul 2012 15:08:27 +0000 (16:08 +0100)
src/bitcoinrpc.cpp
src/checkpoints.cpp
src/checkpoints.h
src/main.cpp
src/serialize.h
src/util.cpp
src/wallet.cpp

index e68f1fe..60c5449 100644 (file)
@@ -307,7 +307,7 @@ Value getinfo(const Array& params, bool fHelp)
             "Returns an object containing various state info.");
 
     Object obj;
-    obj.push_back(Pair("version",       (int)VERSION));
+    obj.push_back(Pair("version",       FormatFullVersion()));
     obj.push_back(Pair("balance",       ValueFromAmount(pwalletMain->GetBalance())));
     obj.push_back(Pair("newmint",       ValueFromAmount(pwalletMain->GetNewMint())));
     obj.push_back(Pair("stake",         ValueFromAmount(pwalletMain->GetStake())));
index 6c28158..d004c84 100644 (file)
@@ -188,9 +188,9 @@ namespace Checkpoints
 
     uint256 AutoSelectSyncCheckpoint()
     {
-        // select block roughly 8 hours ago
+        // select a block some time ago
         CBlockIndex *pindex = mapBlockIndex[hashSyncCheckpoint];
-        while (pindex->pnext && pindex->pnext->GetBlockTime() + AUTO_CHECKPOINT_MIN_SPAN <= GetAdjustedTime())
+        while (pindex->pnext && pindex->pnext->GetBlockTime() + CHECKPOINT_MIN_SPAN <= GetAdjustedTime())
             pindex = pindex->pnext;
         return pindex->GetBlockHash();
     }
@@ -265,7 +265,6 @@ namespace Checkpoints
                 hashPendingCheckpoint = hash;
                 checkpointMessagePending.SetNull();
                 printf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString().c_str());
-                // TODO: when to ask for the checkpoint chain?
             }
 
             BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
index 35cbc65..c09e568 100644 (file)
@@ -8,10 +8,8 @@
 #include <map>
 #include "util.h"
 
-// ppcoin: auto checkpoint min at 8 hours; max at 16 hours
-#define AUTO_CHECKPOINT_MIN_SPAN   (60 * 60 * 8)
-#define AUTO_CHECKPOINT_MAX_SPAN   (60 * 60 * 16)
-#define AUTO_CHECKPOINT_TRUST_SPAN (60 * 60 * 24)
+#define STAKE_MIN_AGE (60 * 60 * 24)      // minimum age for coin age
+#define CHECKPOINT_MIN_SPAN (60 * 60 * 4) // 4 hours checkpoint
 
 class uint256;
 class CBlockIndex;
index b09357a..aaf3f36 100644 (file)
@@ -1338,8 +1338,8 @@ bool CTransaction::CheckProofOfStake(unsigned int nBits) const
     CBlock block;
     if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
         return false; // unable to read block of previous transaction
-    if (block.GetBlockTime() + AUTO_CHECKPOINT_TRUST_SPAN > nTime)
-        return false; // only count coins from at least one week ago
+    if (block.GetBlockTime() + STAKE_MIN_AGE > nTime)
+        return false; // only count coins meeting min age requirement
 
     int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
     CBigNum bnCoinDay = CBigNum(nValueIn) * (nTime-txPrev.nTime) / COIN / (24 * 60 * 60);
@@ -1353,10 +1353,10 @@ bool CTransaction::CheckProofOfStake(unsigned int nBits) const
 }
 
 // ppcoin: total coin age spent in transaction, in the unit of coin-days.
-// Only those coins last spent at least a week ago count. As those
+// Only those coins meeting minimum age requirement counts. As those
 // transactions not in main chain are not currently indexed so we
 // might not find out about their coin age. Older transactions are 
-// guaranteed to be in main chain by auto checkpoint. This rule is
+// guaranteed to be in main chain by sync-checkpoint. This rule is
 // introduced to help nodes establish a consistent view of the coin
 // age (trust score) of competing branches.
 bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const
@@ -1381,8 +1381,8 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const
         CBlock block;
         if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
             return false; // unable to read block of previous transaction
-        if (block.GetBlockTime() + AUTO_CHECKPOINT_TRUST_SPAN > nTime)
-            continue; // only count coins from at least one week ago
+        if (block.GetBlockTime() + STAKE_MIN_AGE > nTime)
+            continue; // only count coins meeting min age requirement
 
         int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
         bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT;
index dafc4b1..61120fd 100644 (file)
@@ -65,6 +65,8 @@ static const int VERSION = 50100;
 static const char* pszSubVer = "";
 static const bool VERSION_IS_BETA = true;
 
+static const int PPCOIN_VERSION = 100;
+
 // Used to bypass the rule against non-const reference to temporary
 // where it makes sense with wrappers such as CFlatData or CTxDB
 template<typename T>
index 1082899..18d0ce8 100644 (file)
@@ -1017,7 +1017,7 @@ string FormatVersion(int nVersion)
 
 string FormatFullVersion()
 {
-    string s = FormatVersion(VERSION) + pszSubVer;
+    string s = FormatVersion(PPCOIN_VERSION) + pszSubVer;
     if (VERSION_IS_BETA) {
         s += "-";
         s += _("beta");
index bab18b6..12fb9fd 100644 (file)
@@ -1115,8 +1115,8 @@ bool CWallet::CreateCoinStake(unsigned int nBits, CTransaction& txNew)
             CBlock block;
             if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
                 continue;
-            if (block.GetBlockTime() + AUTO_CHECKPOINT_TRUST_SPAN > txNew.nTime)
-                continue; // only count coins from at least one week ago
+            if (block.GetBlockTime() + STAKE_MIN_AGE > txNew.nTime)
+                continue; // only count coins meeting min age requirement
 
             int64 nValueIn = pcoin.first->vout[pcoin.second].nValue;
             CBigNum bnCoinDay = CBigNum(nValueIn) * (txNew.nTime-pcoin.first->nTime) / COIN / (24 * 60 * 60);