Skip to content

Commit 4cac471

Browse files
adjust min/max age of stake
1 parent b124ebb commit 4cac471

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/kernel.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
using namespace std;
1111

12-
extern int nStakeMaxAge;
12+
extern unsigned int nStakeMaxAge;
1313
extern unsigned int nTargetSpacing;
1414

1515
typedef std::map<int, unsigned int> MapModifierCheckpoints;
@@ -29,11 +29,9 @@ static std::map<int, unsigned int> mapStakeModifierCheckpointsTestNet =
2929
// Get time weight
3030
int64 GetWeight(int64 nIntervalBeginning, int64 nIntervalEnd)
3131
{
32-
// Kernel hash weight starts from 0 at the 30-day min age
32+
// Kernel hash weight starts from 0 at the min age
3333
// this change increases active coins participating the hash and helps
3434
// to secure the network when proof-of-stake difficulty is low
35-
//
36-
// Maximum TimeWeight is 90 days.
3735

3836
return min(nIntervalEnd - nIntervalBeginning - nStakeMinAge, (int64)nStakeMaxAge);
3937
}

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ CBigNum bnProofOfStakeLimit(~uint256(0) >> 27); // proof of stake target limit s
4141
CBigNum bnProofOfWorkLimitTestNet(~uint256(0) >> 16);
4242

4343
unsigned int nTargetSpacing = 1 * 60; // 1 minute
44-
unsigned int nStakeMinAge = 60 * 60 * 24 * 30; // 30 days as zero time weight
45-
unsigned int nStakeMaxAge = 60 * 60 * 24 * 90; // 90 days as full weight
44+
unsigned int nStakeMinAge = 8 * 60 * 60; // 8 hours
45+
unsigned int nStakeMaxAge = -1; // unlimited
4646
unsigned int nModifierInterval = 6 * 60 * 60; // time to elapse before new modifier is computed
4747

4848
int nCoinbaseMaturity = 500;
@@ -2461,7 +2461,7 @@ bool LoadBlockIndex(bool fAllowNew)
24612461

24622462
bnTrustedModulus.SetHex("f0d14cf72623dacfe738d0892b599be0f31052239cddd95a3f25101c801dc990453b38c9434efe3f372db39a32c2bb44cbaea72d62c8931fa785b0ec44531308df3e46069be5573e49bb29f4d479bfc3d162f57a5965db03810be7636da265bfced9c01a6b0296c77910ebdc8016f70174f0f18a57b3b971ac43a934c6aedbc5c866764a3622b5b7e3f9832b8b3f133c849dbcc0396588abcd1e41048555746e4823fb8aba5b3d23692c6857fccce733d6bb6ec1d5ea0afafecea14a0f6f798b6b27f77dc989c557795cc39a0940ef6bb29a7fc84135193a55bcfc2f01dd73efad1b69f45a55198bd0e6bef4d338e452f6a420f1ae2b1167b923f76633ab6e55");
24632463
bnProofOfWorkLimit = bnProofOfWorkLimitTestNet; // 16 bits PoW target limit for testnet
2464-
nStakeMinAge = 2 * 60 * 60; // test net min age is 2 hours
2464+
nStakeMinAge = 1 * 60 * 60; // test net min age is 1 hour
24652465
nModifierInterval = 20 * 60; // test modifier interval is 20 minutes
24662466
nCoinbaseMaturity = 10; // test maturity is 10 blocks
24672467
}

src/wallet.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <boost/algorithm/string/replace.hpp>
1515

1616
using namespace std;
17-
extern int nStakeMaxAge;
17+
extern unsigned int nStakeMaxAge;
1818

1919
unsigned int nStakeSplitAge = 1 * 24 * 60 * 60;
2020
int64 nStakeCombineThreshold = COIN;
@@ -1497,7 +1497,7 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint
14971497
// Cache outputs unless best block changed
14981498
if (hashPrevBlock != pindexBest->GetBlockHash())
14991499
{
1500-
if (!SelectCoinsSimple(nBalance - nReserveBalance, GetAdjustedTime(), nCoinbaseMaturity * 10, setCoins, nValueIn))
1500+
if (!SelectCoinsSimple(nBalance - nReserveBalance, GetAdjustedTime(), nCoinbaseMaturity + 10, setCoins, nValueIn))
15011501
return false;
15021502
15031503
if (setCoins.empty())
@@ -1510,7 +1510,7 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint
15101510
set<pair<const CWalletTx*,unsigned int> > setCoins;
15111511
int64 nValueIn = 0;
15121512

1513-
if (!SelectCoinsSimple(nBalance - nReserveBalance, GetTime(), nCoinbaseMaturity * 10, setCoins, nValueIn))
1513+
if (!SelectCoinsSimple(nBalance - nReserveBalance, GetTime(), nCoinbaseMaturity + 10, setCoins, nValueIn))
15141514
return false;
15151515

15161516
if (setCoins.empty())
@@ -1586,7 +1586,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
15861586
// Cache outputs unless best block changed
15871587
if (hashPrevBlock != pindexBest->GetBlockHash())
15881588
{
1589-
if (!SelectCoinsSimple(nBalance - nReserveBalance, txNew.nTime, nCoinbaseMaturity * 10, setCoins, nValueIn))
1589+
if (!SelectCoinsSimple(nBalance - nReserveBalance, txNew.nTime, nCoinbaseMaturity + 10, setCoins, nValueIn))
15901590
return false;
15911591
15921592
if (setCoins.empty())
@@ -1600,7 +1600,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
16001600
int64 nValueIn = 0;
16011601

16021602
// Select coins with suitable depth
1603-
if (!SelectCoinsSimple(nBalance - nReserveBalance, txNew.nTime, nCoinbaseMaturity * 10, setCoins, nValueIn))
1603+
if (!SelectCoinsSimple(nBalance - nReserveBalance, txNew.nTime, nCoinbaseMaturity + 10, setCoins, nValueIn))
16041604
return false;
16051605

16061606
if (setCoins.empty())
@@ -1735,7 +1735,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
17351735
if (pcoin.first->vout[pcoin.second].nValue >= nStakeCombineThreshold)
17361736
continue;
17371737
// Do not add input that is still too young
1738-
if (nTimeWeight < nStakeMaxAge)
1738+
if (nTimeWeight < nStakeMinAge)
17391739
continue;
17401740

17411741
txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second));

0 commit comments

Comments
 (0)