extern int nStakeMaxAge;
extern int nStakeTargetSpacing;
+typedef std::map<int, unsigned int> MapModifierCheckpoints;
+
// Hard checkpoints of stake modifiers to ensure they are deterministic
static std::map<int, unsigned int> mapStakeModifierCheckpoints =
boost::assign::map_list_of
( 9690, 0x97dcdafau )
( 12661, 0x5d84115du )
( 19600, 0xdded1b8du )
+ ( 21800, 0x0daa1aaau )
+ ( 26174, 0xaf9983dcu )
+ ;
+
+// Hard checkpoints of stake modifiers to ensure they are deterministic (testNet)
+static std::map<int, unsigned int> mapStakeModifierCheckpointsTestNet =
+ boost::assign::map_list_of
+ ( 0, 0x0e00670bu )
;
// Get the last stake modifier and its generation time from a given block
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;
+ //
+ if(fTestNet || (STAKEWEIGHT_SWITCH_TIME < nTimeTx))
+ {
+ // New rule since 01 Jan 2014: Maximum TimeWeight is 90 days.
+ nTimeWeight = min((int64)nTimeTx - txPrev.nTime - nStakeMinAge, (int64)nStakeMaxAge);
+ }
+ else
+ {
+ // Current rule: Maximum TimeWeight is 60 days.
+ nTimeWeight = min((int64)nTimeTx - txPrev.nTime, (int64)nStakeMaxAge) - nStakeMinAge;
+ }
+
CBigNum bnCoinDayWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60);
// Calculate hash
// Check stake modifier hard checkpoints
bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum)
{
- if (fTestNet) return true; // Testnet has no checkpoints
- if (mapStakeModifierCheckpoints.count(nHeight))
- return nStakeModifierChecksum == mapStakeModifierCheckpoints[nHeight];
+ MapModifierCheckpoints& checkpoints = (fTestNet ? mapStakeModifierCheckpointsTestNet : mapStakeModifierCheckpoints);
+
+ if (checkpoints.count(nHeight))
+ return nStakeModifierChecksum == checkpoints[nHeight];
return true;
}