MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / GetDifficulty

Function GetDifficulty

src/rpcblockchain.cpp:23–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
22
23double GetDifficulty(const CBlockIndex* blockindex)
24{
25 // Floating point number that is a multiple of the minimum difficulty,
26 // minimum difficulty = 1.0.
27 if (blockindex == NULL)
28 {
29 if (chainActive.Tip() == NULL)
30 return 1.0;
31 else
32 blockindex = chainActive.Tip();
33 }
34
35 int nShift = (blockindex->nBits >> 24) & 0xff;
36
37 double dDiff =
38 (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
39
40 while (nShift < 29)
41 {
42 dDiff *= 256.0;
43 nShift++;
44 }
45 while (nShift > 29)
46 {
47 dDiff /= 256.0;
48 nShift--;
49 }
50
51 return dDiff;
52}
53
54UniValue blockheaderToJSON(const CBlockIndex* blockindex)
55{

Callers 6

blockheaderToJSONFunction · 0.85
blockToJSONFunction · 0.85
getdifficultyFunction · 0.85
getblockchaininfoFunction · 0.85
getinfoFunction · 0.85
getmininginfoFunction · 0.85

Calls 1

TipMethod · 0.45

Tested by

no test coverage detected