mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
updated POW settings
This commit is contained in:
parent
873aa6ad69
commit
3ce6e54574
88
src/main.cpp
88
src/main.cpp
@ -1515,83 +1515,6 @@ unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBloc
|
|||||||
return bnNew.GetCompact();
|
return bnNew.GetCompact();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
|
|
||||||
/* current difficulty formula, darkcoin - DarkGravity v2, written by Evan Duffield - evan@darkcoin.io */
|
|
||||||
const CBlockIndex *BlockLastSolved = pindexLast;
|
|
||||||
const CBlockIndex *BlockReading = pindexLast;
|
|
||||||
const CBlockHeader *BlockCreating = pblock;
|
|
||||||
BlockCreating = BlockCreating;
|
|
||||||
int64 nBlockTimeAverage = 0;
|
|
||||||
int64 nBlockTimeAveragePrev = 0;
|
|
||||||
int64 nBlockTimeCount = 0;
|
|
||||||
int64 nBlockTimeSum2 = 0;
|
|
||||||
int64 nBlockTimeCount2 = 0;
|
|
||||||
int64 LastBlockTime = 0;
|
|
||||||
int64 PastBlocksMin = 14;
|
|
||||||
int64 PastBlocksMax = 140;
|
|
||||||
int64 CountBlocks = 0;
|
|
||||||
CBigNum PastDifficultyAverage;
|
|
||||||
CBigNum PastDifficultyAveragePrev;
|
|
||||||
|
|
||||||
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || BlockLastSolved->nHeight < PastBlocksMin) { return bnProofOfWorkLimit.GetCompact(); }
|
|
||||||
|
|
||||||
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
|
|
||||||
if (PastBlocksMax > 0 && i > PastBlocksMax) { break; }
|
|
||||||
CountBlocks++;
|
|
||||||
|
|
||||||
if(CountBlocks <= PastBlocksMin) {
|
|
||||||
if (CountBlocks == 1) { PastDifficultyAverage.SetCompact(BlockReading->nBits); }
|
|
||||||
else { PastDifficultyAverage = ((CBigNum().SetCompact(BlockReading->nBits) - PastDifficultyAveragePrev) / CountBlocks) + PastDifficultyAveragePrev; }
|
|
||||||
PastDifficultyAveragePrev = PastDifficultyAverage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(LastBlockTime > 0){
|
|
||||||
int64 Diff = (LastBlockTime - BlockReading->GetBlockTime());
|
|
||||||
if(nBlockTimeCount <= PastBlocksMin) {
|
|
||||||
nBlockTimeCount++;
|
|
||||||
|
|
||||||
if (nBlockTimeCount == 1) { nBlockTimeAverage = Diff; }
|
|
||||||
else { nBlockTimeAverage = ((Diff - nBlockTimeAveragePrev) / nBlockTimeCount) + nBlockTimeAveragePrev; }
|
|
||||||
nBlockTimeAveragePrev = nBlockTimeAverage;
|
|
||||||
}
|
|
||||||
nBlockTimeCount2++;
|
|
||||||
nBlockTimeSum2 += Diff;
|
|
||||||
}
|
|
||||||
LastBlockTime = BlockReading->GetBlockTime();
|
|
||||||
|
|
||||||
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
|
|
||||||
BlockReading = BlockReading->pprev;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBigNum bnNew(PastDifficultyAverage);
|
|
||||||
if (nBlockTimeCount != 0 && nBlockTimeCount2 != 0) {
|
|
||||||
double SmartAverage = ((((long double)nBlockTimeAverage)*0.7)+(((long double)nBlockTimeSum2 / (long double)nBlockTimeCount2)*0.3));
|
|
||||||
if(SmartAverage < 1) SmartAverage = 1;
|
|
||||||
double Shift = nTargetSpacing/SmartAverage;
|
|
||||||
|
|
||||||
double fActualTimespan = ((long double)CountBlocks*(double)nTargetSpacing)/Shift;
|
|
||||||
double fTargetTimespan = ((long double)CountBlocks*(double)nTargetSpacing);
|
|
||||||
|
|
||||||
if (fActualTimespan < fTargetTimespan/3)
|
|
||||||
fActualTimespan = fTargetTimespan/3;
|
|
||||||
if (fActualTimespan > fTargetTimespan*3)
|
|
||||||
fActualTimespan = fTargetTimespan*3;
|
|
||||||
|
|
||||||
int64 nActualTimespan = fActualTimespan;
|
|
||||||
int64 nTargetTimespan = fTargetTimespan;
|
|
||||||
|
|
||||||
// Retarget
|
|
||||||
bnNew *= nActualTimespan;
|
|
||||||
bnNew /= nTargetTimespan;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bnNew > bnProofOfWorkLimit){
|
|
||||||
bnNew = bnProofOfWorkLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bnNew.GetCompact();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
|
unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
|
||||||
/* current difficulty formula, darkcoin - DarkGravity v3, written by Evan Duffield - evan@darkcoin.io */
|
/* current difficulty formula, darkcoin - DarkGravity v3, written by Evan Duffield - evan@darkcoin.io */
|
||||||
const CBlockIndex *BlockLastSolved = pindexLast;
|
const CBlockIndex *BlockLastSolved = pindexLast;
|
||||||
@ -1665,19 +1588,18 @@ unsigned int static GetNextWorkRequired_V2(const CBlockIndex* pindexLast, const
|
|||||||
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
|
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
|
||||||
{
|
{
|
||||||
int DiffMode = 1;
|
int DiffMode = 1;
|
||||||
|
|
||||||
if (fTestNet) {
|
if (fTestNet) {
|
||||||
if (pindexLast->nHeight+1 >= 16) { DiffMode = 4; }
|
if (pindexLast->nHeight+1 >= 256) DiffMode = 3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pindexLast->nHeight+1 >= 68589) { DiffMode = 4; }
|
if (pindexLast->nHeight+1 >= 34140) DiffMode = 3;
|
||||||
else if (pindexLast->nHeight+1 >= 34140) { DiffMode = 3; }
|
else if (pindexLast->nHeight+1 >= 15200) DiffMode = 2;
|
||||||
else if (pindexLast->nHeight+1 >= 15200) { DiffMode = 2; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DiffMode == 1) { return GetNextWorkRequired_V1(pindexLast, pblock); }
|
if (DiffMode == 1) { return GetNextWorkRequired_V1(pindexLast, pblock); }
|
||||||
else if (DiffMode == 2) { return GetNextWorkRequired_V2(pindexLast, pblock); }
|
else if (DiffMode == 2) { return GetNextWorkRequired_V2(pindexLast, pblock); }
|
||||||
else if (DiffMode == 3) { return DarkGravityWave(pindexLast, pblock); }
|
else if (DiffMode == 3) { return DarkGravityWave3(pindexLast, pblock); }
|
||||||
else if (DiffMode == 4) { return DarkGravityWave3(pindexLast, pblock); }
|
|
||||||
return DarkGravityWave3(pindexLast, pblock);
|
return DarkGravityWave3(pindexLast, pblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user