Advertisement
Guest User

Pennies Sync Patch

a guest
Jan 11th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.45 KB | None | 0 0
  1. diff --git a/src/main.cpp b/src/main.cpp
  2. index f82e239..4642db9 100644
  3. --- a/src/main.cpp
  4. +++ b/src/main.cpp
  5. @@ -985,21 +985,20 @@ int64 GetProofOfWorkReward(unsigned int nBits)
  6.  }
  7.  
  8.  // ppcoin: miner's coin stake is rewarded based on coin age spent (coin-days)
  9. -int64 GetProofOfStakeReward(int64 nCoinAge)
  10. +int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nTime)
  11.  {
  12.      static int64 nRewardCoinYear = 1;  // creation amount per coin-year
  13.      int64 nSubsidy = nCoinAge * 1 * nRewardCoinYear;
  14.  
  15.      // Reduce stake drastically 7 days after we stop accepting connections/blocks from
  16.      // older clients. (8th January 2014 at 00:00:00 GMT)
  17. -    int64 currentTimestamp = GetTime();
  18. -    if(currentTimestamp >= 1389139200)
  19. +    if (nTime >= STAKE_SWITCH_TIME)
  20.      {
  21.          nSubsidy = nCoinAge * 0.0001 * nRewardCoinYear;
  22.      }
  23.      if (fDebug && GetBoolArg("-printcreation"))
  24.          {printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d"\n", FormatMoney(nSubsidy).c_str(), nCoinAge);}
  25. -          
  26. +
  27.      return nSubsidy;
  28.  }
  29.  
  30. @@ -1392,7 +1391,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs,
  31.              if (!GetCoinAge(txdb, nCoinAge))
  32.                  return error("ConnectInputs() : %s unable to get coin age for coinstake", GetHash().ToString().substr(0,10).c_str());
  33.              int64 nStakeReward = GetValueOut() - nValueIn;
  34. -            if (nStakeReward > GetProofOfStakeReward(nCoinAge) - GetMinFee() + MIN_TX_FEE)
  35. +            if (nStakeReward > GetProofOfStakeReward(nCoinAge, nTime) - GetMinFee() + MIN_TX_FEE)
  36.                  return DoS(100, error("ConnectInputs() : %s stake reward exceeded", GetHash().ToString().substr(0,10).c_str()));
  37.          }
  38.          else
  39. diff --git a/src/main.h b/src/main.h
  40. index 8147a12..e811268 100644
  41. --- a/src/main.h
  42. +++ b/src/main.h
  43. @@ -35,6 +35,9 @@ static const int64 MIN_RELAY_TX_FEE = 0;
  44.  static const int64 MAX_MONEY = 1000000000 * CENT;
  45.  static const int64 MAX_MINT_PROOF_OF_WORK = 1 * CENT;
  46.  static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE;
  47. +
  48. +static const unsigned int STAKE_SWITCH_TIME = 1389139200; // Wed, 08 Jan 2014 00:00:00 GMT
  49. +
  50.  inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
  51.  // Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
  52.  static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov  5 00:53:20 1985 UTC
  53. @@ -115,7 +118,7 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash
  54.  bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
  55.  bool CheckProofOfWork(uint256 hash, unsigned int nBits);
  56.  int64 GetProofOfWorkReward(unsigned int nBits);
  57. -int64 GetProofOfStakeReward(int64 nCoinAge);
  58. +int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nTime);
  59.  unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
  60.  int GetNumBlocksOfPeers();
  61.  bool IsInitialBlockDownload();
  62. diff --git a/src/wallet.cpp b/src/wallet.cpp
  63. index 92c17d5..bdf7293 100644
  64. --- a/src/wallet.cpp
  65. +++ b/src/wallet.cpp
  66. @@ -1503,7 +1503,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
  67.          CTxDB txdb("r");
  68.          if (!txNew.GetCoinAge(txdb, nCoinAge))
  69.              return error("CreateCoinStake : failed to calculate coin age");
  70. -        nCredit += GetProofOfStakeReward(nCoinAge);
  71. +        nCredit += GetProofOfStakeReward(nCoinAge, txNew.nTime);
  72.      }
  73.  
  74.      int64 nMinFee = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement