From 25f30f6d47cc05a5879c578d4ca4315efab9e605 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 28 Jul 2013 02:25:03 +0400 Subject: [PATCH] Add PoS ROI curve switch since 20 Oct 2013 --- src/main.cpp | 46 +++++++++++++++++++++++++++++++++++----------- src/main.h | 1 + 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 655046f..6660af6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1008,22 +1008,46 @@ int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTi CBigNum bnTargetLimit = GetProofOfStakeLimit(0, nTime); bnTargetLimit.SetCompact(bnTargetLimit.GetCompact()); - // NovaCoin: reward for coin-year is cut in half every 64x multiply of PoS difficulty - // A reasonably continuous curve is used to avoid shock to market - // (nRewardCoinYearLimit / nRewardCoinYear) ** 6 == bnProofOfStakeLimit / bnTarget - // - // Human readable form: - // - // nRewardCoinYear = 1 / (posdiff ^ 1/6) + // NovaCoin: A reasonably continuous curve is used to avoid shock to market + + CBigNum bnLowerBound = 1 * CENT, // Lower interest bound is 1% per year + bnUpperBound = bnRewardCoinYearLimit, // Upper interest bound is 100% per year + bnMidPart, bnRewardPart; - CBigNum bnLowerBound = 1 * CENT; // Lower interest bound is 1% per year - CBigNum bnUpperBound = bnRewardCoinYearLimit; while (bnLowerBound + CENT <= bnUpperBound) { CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2; if (fDebug && GetBoolArg("-printcreation")) printf("GetProofOfStakeReward() : lower=%"PRI64d" upper=%"PRI64d" mid=%"PRI64d"\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64()); - if (bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnTargetLimit > bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnTarget) + + if(!fTestNet && nTime < STAKECURVE_SWITCH_TIME) + { + // + // Until 20 Oct 2013: reward for coin-year is cut in half every 64x multiply of PoS difficulty + // + // (nRewardCoinYearLimit / nRewardCoinYear) ** 6 == bnProofOfStakeLimit / bnTarget + // + // Human readable form: nRewardCoinYear = 1 / (posdiff ^ 1/6) + // + + bnMidPart = bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnTargetLimit; + bnRewardPart = bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnTarget; + } + else + { + // + // Until 20 Oct 2013: reward for coin-year is cut in half every 8x multiply of PoS difficulty + // + // (nRewardCoinYearLimit / nRewardCoinYear) ** 3 == bnProofOfStakeLimit / bnTarget + // + // Human readable form: nRewardCoinYear = 1 / (posdiff ^ 1/3) + // + + bnMidPart = bnMidValue * bnMidValue * bnMidValue * bnTargetLimit; + bnRewardPart = bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnTarget; + } + + if (bnMidPart > bnRewardPart) bnUpperBound = bnMidValue; else bnLowerBound = bnMidValue; diff --git a/src/main.h b/src/main.h index d09dc63..555a312 100644 --- a/src/main.h +++ b/src/main.h @@ -40,6 +40,7 @@ static const unsigned int STAKE_SWITCH_TIME = 1371686400; // 20 Jun 2013 00:00:0 static const unsigned int TARGETS_SWITCH_TIME = 1374278400; // 20 Jul 2013 00:00:00 static const unsigned int LOCKS_SWITCH_TIME = 1376956800; // 20 Aug 2013 00:00:00 static const unsigned int CHAINCHECKS_SWITCH_TIME = 1379635200; // 20 Sep 2013 00:00:00 +static const unsigned int STAKECURVE_SWITCH_TIME = 1382227200; // 20 Oct 2013 00:00:00 inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } // Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. -- 1.7.1