MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetDifficulty

Function GetDifficulty

src/rpc/blockchain.cpp:83–103  ·  view source on GitHub ↗

Calculate the difficulty for a given block index. */

Source from the content-addressed store, hash-verified

81/* Calculate the difficulty for a given block index.
82 */
83double GetDifficulty(const CBlockIndex* blockindex)
84{
85 CHECK_NONFATAL(blockindex);
86
87 int nShift = (blockindex->nBits >> 24) & 0xff;
88 double dDiff =
89 (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
90
91 while (nShift < 29)
92 {
93 dDiff *= 256.0;
94 nShift++;
95 }
96 while (nShift > 29)
97 {
98 dDiff /= 256.0;
99 nShift--;
100 }
101
102 return dDiff;
103}
104
105UniValue paramEntryToJSON(const DynaFedParamEntry& entry)
106{

Callers 5

TestDifficultyFunction · 0.85
getmininginfoFunction · 0.85
blockheaderToJSONFunction · 0.85
getdifficultyFunction · 0.85
getblockchaininfoFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDifficultyFunction · 0.68