This commit is contained in:
jl777
2019-08-02 05:01:38 -11:00
parent 40f18eeca5
commit 3cf10af4ee
3 changed files with 8 additions and 7 deletions

View File

@@ -5296,7 +5296,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
} }
// Check timestamp against prev // Check timestamp against prev
if ( ASSETCHAINS_ADAPTIVEPOW == 0 || nHeight < 30 ) if ( ASSETCHAINS_ADAPTIVEPOW <= 0 || nHeight < 30 )
{ {
if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast() ) if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast() )
{ {

View File

@@ -123,12 +123,13 @@ public:
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
{ {
if ( ASSETCHAINS_ADAPTIVEPOW == 0 ) if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime());
// Updating time can change work required on testnet: // Updating time can change work required on testnet:
if (consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != boost::none) { if (ASSETCHAINS_ADAPTIVEPOW > 0 || consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != boost::none)
{
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
} }
} }
@@ -569,7 +570,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
nLastBlockTx = nBlockTx; nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize; nLastBlockSize = nBlockSize;
if ( ASSETCHAINS_ADAPTIVEPOW == 0 ) if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime());
//pblock->nTime = blocktime + 1; //pblock->nTime = blocktime + 1;
@@ -644,7 +645,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
//fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
txNew.nExpiryHeight = 0; txNew.nExpiryHeight = 0;
if ( ASSETCHAINS_ADAPTIVEPOW == 0 ) if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime());

View File

@@ -89,7 +89,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
{ {
blocktime = pindexFirst->nTime; blocktime = pindexFirst->nTime;
diff = (pblock->nTime - blocktime); diff = (pblock->nTime - blocktime);
fprintf(stderr,"%d ",diff); //fprintf(stderr,"%d ",diff);
if ( i < 12 ) if ( i < 12 )
{ {
if ( i == 3 ) if ( i == 3 )
@@ -104,7 +104,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
} }
pindexFirst = pindexFirst->pprev; pindexFirst = pindexFirst->pprev;
} }
fprintf(stderr,"diffs %d\n",(int32_t) pindexLast->GetHeight()); //fprintf(stderr,"diffs %d\n",(int32_t) pindexLast->GetHeight());
// Check we have enough blocks // Check we have enough blocks
if (pindexFirst == NULL) if (pindexFirst == NULL)
return nProofOfWorkLimit; return nProofOfWorkLimit;