Browse Source

Tet

pull/37/head
jl777 5 years ago
parent
commit
3cf10af4ee
  1. 2
      src/main.cpp
  2. 9
      src/miner.cpp
  3. 4
      src/pow.cpp

2
src/main.cpp

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

9
src/miner.cpp

@ -123,12 +123,13 @@ public:
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());
else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime());
// 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);
}
}
@ -569,7 +570,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
if ( ASSETCHAINS_ADAPTIVEPOW == 0 )
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime());
//pblock->nTime = blocktime + 1;
@ -644,7 +645,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
//fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
txNew.nExpiryHeight = 0;
if ( ASSETCHAINS_ADAPTIVEPOW == 0 )
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime());

4
src/pow.cpp

@ -89,7 +89,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
{
blocktime = pindexFirst->nTime;
diff = (pblock->nTime - blocktime);
fprintf(stderr,"%d ",diff);
//fprintf(stderr,"%d ",diff);
if ( i < 12 )
{
if ( i == 3 )
@ -104,7 +104,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
}
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
if (pindexFirst == NULL)
return nProofOfWorkLimit;

Loading…
Cancel
Save