mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-02-21 04:38:53 +00:00
Merge pull request #1213 from langerhans/1.10-dev-maturity
Minor fixes to concensus relevant parameters
This commit is contained in:
commit
d988dc7ba0
@ -7,6 +7,7 @@
|
||||
|
||||
#include "auxpow.h"
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "main.h"
|
||||
#include "script/script.h"
|
||||
@ -89,7 +90,8 @@ int CMerkleTx::GetBlocksToMaturity() const
|
||||
{
|
||||
if (!IsCoinBase())
|
||||
return 0;
|
||||
return std::max(0, (COINBASE_MATURITY + 1) - GetDepthInMainChain());
|
||||
int nCoinbaseMaturity = Params().GetConsensus(chainActive.Height()).nCoinbaseMaturity;
|
||||
return std::max(0, (nCoinbaseMaturity + 1) - GetDepthInMainChain());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ public:
|
||||
consensus.fAllowLegacyBlocks = true;
|
||||
consensus.nHeightEffective = 0;
|
||||
consensus.fDigishieldDifficultyCalculation = false;
|
||||
consensus.nCoinbaseMaturity = 30;
|
||||
|
||||
// Blocks 145000 - 371336 are Digishield without AuxPoW
|
||||
digishieldConsensus = consensus;
|
||||
@ -58,6 +59,7 @@ public:
|
||||
digishieldConsensus.fSimplifiedRewards = true;
|
||||
digishieldConsensus.fDigishieldDifficultyCalculation = true;
|
||||
digishieldConsensus.nPowTargetTimespan = 60; // post-digishield: 1 minute
|
||||
digishieldConsensus.nCoinbaseMaturity = 240;
|
||||
|
||||
// Blocks 371337+ are AuxPoW
|
||||
auxpowConsensus = digishieldConsensus;
|
||||
@ -203,6 +205,7 @@ public:
|
||||
digishieldConsensus.fDigishieldDifficultyCalculation = true;
|
||||
digishieldConsensus.fSimplifiedRewards = true;
|
||||
digishieldConsensus.fPowAllowMinDifficultyBlocks = false;
|
||||
digishieldConsensus.nCoinbaseMaturity = 240;
|
||||
|
||||
// Blocks 157500 - 158099 are Digishield with minimum difficulty on all blocks
|
||||
minDifficultyConsensus = digishieldConsensus;
|
||||
@ -285,9 +288,11 @@ public:
|
||||
consensus.nMajorityRejectBlockOutdated = 950;
|
||||
consensus.nMajorityWindow = 1000;
|
||||
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
|
||||
consensus.nPowTargetSpacing = 1; // regtest: 1 second blocks
|
||||
consensus.powLimit = uint256S("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1;
|
||||
consensus.fStrictChainId = true;
|
||||
consensus.fAllowLegacyBlocks = false; // Never allow legacy blocks on RegTest
|
||||
consensus.fSimplifiedRewards = true;
|
||||
|
||||
// Reset links before we copy parameters
|
||||
consensus.pLeft = NULL;
|
||||
@ -295,7 +300,7 @@ public:
|
||||
|
||||
digishieldConsensus = consensus;
|
||||
digishieldConsensus.nHeightEffective = 10;
|
||||
digishieldConsensus.nPowTargetTimespan = 60; // post-digishield: 1 minute
|
||||
digishieldConsensus.nPowTargetTimespan = 1; // // regtest: also retarget every second in digishield mode, for conformity
|
||||
digishieldConsensus.fDigishieldDifficultyCalculation = true;
|
||||
|
||||
auxpowConsensus = digishieldConsensus;
|
||||
|
||||
@ -10,12 +10,6 @@
|
||||
static const unsigned int MAX_BLOCK_SIZE = 1000000;
|
||||
/** The maximum allowed number of signature check operations in a block (network rule) */
|
||||
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
||||
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
|
||||
static const int COINBASE_MATURITY = 60*4; // 4 hours of blocks
|
||||
/** Coinbase maturity before block 145000 **/
|
||||
static const int COINBASE_MATURITY_OLD = 30;
|
||||
/** Block at which COINBASE_MATURITY_OLD was deprecated **/
|
||||
static const int COINBASE_MATURITY_SWITCH = 145000;
|
||||
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */
|
||||
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ struct Params {
|
||||
int nMajorityEnforceBlockUpgrade;
|
||||
int nMajorityRejectBlockOutdated;
|
||||
int nMajorityWindow;
|
||||
int nCoinbaseMaturity;
|
||||
/** Proof of work parameters */
|
||||
uint256 powLimit;
|
||||
bool fPowAllowMinDifficultyBlocks;
|
||||
|
||||
@ -1448,9 +1448,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
|
||||
// If prev is coinbase, check that it's matured
|
||||
if (coins->IsCoinBase()) {
|
||||
// Dogecoin: Switch maturity at depth 145,000
|
||||
int nCoinbaseMaturity = coins->nHeight < COINBASE_MATURITY_SWITCH
|
||||
? COINBASE_MATURITY_OLD
|
||||
: COINBASE_MATURITY;
|
||||
int nCoinbaseMaturity = Params().GetConsensus(coins->nHeight).nCoinbaseMaturity;
|
||||
if (nSpendHeight - coins->nHeight < nCoinbaseMaturity)
|
||||
return state.Invalid(
|
||||
error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "transactionrecord.h"
|
||||
|
||||
#include "base58.h"
|
||||
#include "chainparams.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "main.h"
|
||||
#include "script/script.h"
|
||||
@ -264,8 +265,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
|
||||
if (wtx.IsCoinBase())
|
||||
{
|
||||
quint32 numBlocksToMaturity = COINBASE_MATURITY + 1;
|
||||
strHTML += "<br>" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(numBlocksToMaturity)) + "<br>";
|
||||
quint32 nCoinbaseMaturity = Params().GetConsensus(chainActive.Height()).nCoinbaseMaturity + 1;
|
||||
strHTML += "<br>" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(nCoinbaseMaturity)) + "<br>";
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
#include "txmempool.h"
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "clientversion.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "consensus/validation.h"
|
||||
@ -166,7 +167,8 @@ void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache *pcoins, unsigned in
|
||||
continue;
|
||||
const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
|
||||
if (fSanityCheck) assert(coins);
|
||||
if (!coins || (coins->IsCoinBase() && nMemPoolHeight - coins->nHeight < COINBASE_MATURITY)) {
|
||||
int nCoinbaseMaturity = Params().GetConsensus(coins->nHeight).nCoinbaseMaturity;
|
||||
if (!coins || (coins->IsCoinBase() && nMemPoolHeight - coins->nHeight < nCoinbaseMaturity)) {
|
||||
transactionsToRemove.push_back(tx);
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user