PPCoin: Set stake full weight age at 90 days
authorSunny King <sunnyking9999@gmail.com>
Wed, 29 Aug 2012 14:30:01 +0000 (15:30 +0100)
committerSunny King <sunnyking9999@gmail.com>
Wed, 29 Aug 2012 14:30:01 +0000 (15:30 +0100)
        This switches the hashing protocol from a pure coin age weighted
        model more toward a coin-weighted model

src/checkpoints.h
src/main.cpp
src/wallet.cpp

index 9c1f91d..3255412 100644 (file)
@@ -10,6 +10,7 @@
 #include "util.h"
 
 #define STAKE_MIN_AGE (60 * 60 * 24 * 30) // minimum age 30 days for coin age
+#define STAKE_MAX_AGE (60 * 60 * 24 * 90) // stake age for full weight
 #define CHECKPOINT_MAX_SPAN (60 * 60 * 4) // max 4 hours before latest block
 
 class uint256;
index da773ce..f2c7b51 100644 (file)
@@ -1727,7 +1727,7 @@ bool CTransaction::CheckProofOfStake(unsigned int nBits) const
         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);
+    CBigNum bnCoinDay = CBigNum(nValueIn) * min(nTime-txPrev.nTime, (unsigned int)STAKE_MAX_AGE) / COIN / (24 * 60 * 60);
     // Calculate hash
     CDataStream ss(SER_GETHASH, 0);
     ss << nBits << block.nTime << (txindex.pos.nTxPos - txindex.pos.nBlockPos) << txPrev.nTime << txin.prevout.n << nTime;
index 2612aa6..47ef64f 100644 (file)
@@ -1251,7 +1251,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, CTr
             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);
+        CBigNum bnCoinDay = CBigNum(nValueIn) * min(txNew.nTime-pcoin.first->nTime, (unsigned int)STAKE_MAX_AGE) / COIN / (24 * 60 * 60);
         // Calculate hash
         CDataStream ss(SER_GETHASH, 0);
         ss << nBits << block.nTime << (txindex.pos.nTxPos - txindex.pos.nBlockPos) << pcoin.first->nTime << pcoin.second << txNew.nTime;