From b43972dc5dabf467a997f51b24d561641a0c6514 Mon Sep 17 00:00:00 2001 From: Sunny King Date: Wed, 29 Aug 2012 15:30:01 +0100 Subject: [PATCH] PPCoin: Set stake full weight age at 90 days This switches the hashing protocol from a pure coin age weighted model more toward a coin-weighted model --- src/checkpoints.h | 1 + src/main.cpp | 2 +- src/wallet.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/checkpoints.h b/src/checkpoints.h index 9c1f91d..3255412 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -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; diff --git a/src/main.cpp b/src/main.cpp index da773ce..f2c7b51 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; diff --git a/src/wallet.cpp b/src/wallet.cpp index 2612aa6..47ef64f 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -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; -- 1.7.1