PPCoin: Use nMaxClockDrift with CreateCoinStake
authorSunny King <sunnyking9999@gmail.com>
Mon, 17 Sep 2012 14:39:31 +0000 (15:39 +0100)
committerSunny King <sunnyking9999@gmail.com>
Mon, 17 Sep 2012 14:39:31 +0000 (15:39 +0100)
src/main.cpp
src/main.h
src/wallet.cpp

index cb85469..a419f7f 100644 (file)
@@ -869,7 +869,6 @@ int64 GetProofOfStakeReward(int64 nCoinAge)
 static const int64 nTargetTimespan = 7 * 24 * 60 * 60;  // one week
 static const int64 nTargetSpacingStake = 10 * 60;       // ten minutes
 static const int64 nTargetSpacingWorkMax = 2 * 60 * 60; // two hours
-static const int64 nMaxClockDrift = 2 * 60 * 60;        // two hours
 
 //
 // minimum amount of work that could possibly be required nTime after
index 2cde696..60e4832 100644 (file)
@@ -50,6 +50,8 @@ static const int fHaveUPnP = false;
 static const uint256 hashGenesisBlockOfficial("0x0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3");
 static const uint256 hashGenesisBlockTestNet("0x00000001f757bb737f6596503e17cd17b0658ce630cc727c0cca81aec47c9f06");
 
+static const int64 nMaxClockDrift = 2 * 60 * 60;        // two hours
+
 extern CScript COINBASE_FLAGS;
 
 
index 1066dff..be8fccf 100644 (file)
@@ -1247,7 +1247,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
         CBlock block;
         if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
             continue;
-        if (block.GetBlockTime() + nStakeMinAge > txNew.nTime - (60 * 60 * 2))
+        if (block.GetBlockTime() + nStakeMinAge > txNew.nTime - nMaxClockDrift)
             continue; // only count coins meeting min age requirement
 
         int64 nValueIn = pcoin.first->vout[pcoin.second].nValue;
@@ -1257,7 +1257,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
         for (int n=0; n<min(nSearchInterval,(int64)5) && !fKernelFound && !fShutdown; n++)
         {
             // Randomly pick a timestamp from protocol allowed range
-            txNew.nTime = GetAdjustedTime() - GetRandInt(60 * 60 * 2 - 60);
+            txNew.nTime = GetAdjustedTime() - GetRandInt(nMaxClockDrift - 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;