From b9289ef1acf9c6c6146c573955443f555abb9351 Mon Sep 17 00:00:00 2001 From: alexhz Date: Sun, 11 Aug 2013 20:57:03 +0000 Subject: [PATCH] nTimeWeight calculation issue Originally it was planned to start nTimeWeight calculation from zero at the 30-day min age. This should increase active coins participating the hash and help to secure the network when proof-of-stake difficulty is low. Anyway, this feature is disabled for now and needs some discussion. --- src/kernel.cpp | 13 +++++++++++-- src/main.h | 12 +++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/kernel.cpp b/src/kernel.cpp index 96933b6..89ffdab 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -274,10 +274,19 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned bnTargetPerCoinDay.SetCompact(nBits); int64 nValueIn = txPrev.vout[prevout.n].nValue; - // v0.3 protocol kernel hash weight starts from 0 at the 30-day min age + int64 nTimeWeight; + + // Kernel hash weight starts from 0 at the 30-day min age // this change increases active coins participating the hash and helps // to secure the network when proof-of-stake difficulty is low - int64 nTimeWeight = min((int64)nTimeTx - txPrev.nTime, (int64)nStakeMaxAge) - nStakeMinAge; + // + // Disabled for the moment, needs some discussion. That's planned to make this active since 01 Jan 2014 + + if(fTestNet || (false && STAKEWEIGHT_SWITCH_TIME < nTimeTx)) + nTimeWeight = min((int64)nTimeTx - txPrev.nTime - nStakeMinAge, (int64)nStakeMaxAge); + else + nTimeWeight = min((int64)nTimeTx - txPrev.nTime, (int64)nStakeMaxAge) - nStakeMinAge; + CBigNum bnCoinDayWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); // Calculate hash diff --git a/src/main.h b/src/main.h index 6be9612..0e2af16 100644 --- a/src/main.h +++ b/src/main.h @@ -36,11 +36,13 @@ static const int64 MAX_MONEY = 2000000000 * COIN; static const int64 MAX_MINT_PROOF_OF_WORK = 100 * COIN; static const int64 MAX_MINT_PROOF_OF_STAKE = 1 * COIN; static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE; -static const unsigned int STAKE_SWITCH_TIME = 1371686400; // 20 Jun 2013 00:00:00 -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 +static const unsigned int STAKE_SWITCH_TIME = 1371686400; // Thu, 20 Jun 2013 00:00:00 GMT +static const unsigned int TARGETS_SWITCH_TIME = 1374278400; // Sat, 20 Jul 2013 00:00:00 GMT +static const unsigned int LOCKS_SWITCH_TIME = 1376956800; // Tue, 20 Aug 2013 00:00:00 GMT +static const unsigned int CHAINCHECKS_SWITCH_TIME = 1379635200; // Fri, 20 Sep 2013 00:00:00 GMT +static const unsigned int STAKECURVE_SWITCH_TIME = 1382227200; // Sun, 20 Oct 2013 00:00:00 GMT +static const unsigned int STAKEWEIGHT_SWITCH_TIME = 1388534400; // Wed, 01 Jan 2014 00:00:00 GMT + 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