Merge pull request #131 from donshin/network-difficulty-comparability
Calculate network difficulty based on legacy powLimit value
This commit is contained in:
commit
1d8429d6db
|
@ -41,13 +41,14 @@ double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficul
|
||||||
bits = blockindex->nBits;
|
bits = blockindex->nBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t powLimit =
|
// instead of using powLimit, network difficulty is calculated using a legacy powLimit value to maintain comparability with the network difficulty of other Equihash-based coins for mining profitability calculations.
|
||||||
UintToArith256(Params().GetConsensus().powLimit).GetCompact();
|
uint32_t powLimitLegacy =
|
||||||
|
UintToArith256(uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")).GetCompact();
|
||||||
int nShift = (bits >> 24) & 0xff;
|
int nShift = (bits >> 24) & 0xff;
|
||||||
int nShiftAmount = (powLimit >> 24) & 0xff;
|
int nShiftAmount = (powLimitLegacy >> 24) & 0xff;
|
||||||
|
|
||||||
double dDiff =
|
double dDiff =
|
||||||
(double)(powLimit & 0x00ffffff) /
|
(double)(powLimitLegacy & 0x00ffffff) /
|
||||||
(double)(bits & 0x00ffffff);
|
(double)(bits & 0x00ffffff);
|
||||||
|
|
||||||
while (nShift < nShiftAmount)
|
while (nShift < nShiftAmount)
|
||||||
|
@ -61,6 +62,9 @@ double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficul
|
||||||
nShift--;
|
nShift--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for compatibility purposes, the floor of 1.0 is maintained.
|
||||||
|
if (dDiff < 1) dDiff = 1.0;
|
||||||
|
|
||||||
return dDiff;
|
return dDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue