Attempt to fix testnet

This commit is contained in:
lateminer
2018-10-17 00:40:44 +03:00
parent f57cc59be2
commit eb242178e1
7 changed files with 179 additions and 164 deletions

View File

@@ -30,22 +30,21 @@ static arith_uint256 GetTargetLimit(int64_t nTime, const Consensus::Params& para
unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params, bool fProofOfStake)
{
unsigned int nTargetLimit = GetTargetLimit(pindexLast->GetBlockTime(), params, fProofOfStake).GetCompact();
// Genesis block
if (pindexLast == NULL)
return UintToArith256(params.powLimit).GetCompact();
else {
unsigned int nTargetLimit = GetTargetLimit(pindexLast->GetBlockTime(), params, fProofOfStake).GetCompact();
const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake);
const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake);
if (pindexPrev->pprev == NULL)
return nTargetLimit; // first block
const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake);
if (pindexPrevPrev->pprev == NULL)
return nTargetLimit; // second block
if (pindexPrev->pprev == NULL)
return nTargetLimit; // first block
const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake);
if (pindexPrevPrev->pprev == NULL)
return nTargetLimit; // second block
return CalculateNextTargetRequired(pindexPrev, pindexPrevPrev->GetBlockTime(), params, fProofOfStake);
}
return CalculateNextTargetRequired(pindexPrev, pindexPrevPrev->GetBlockTime(), params, fProofOfStake);
}
unsigned int CalculateNextTargetRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params, bool fProofOfStake)