MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetDifficulty

Function GetDifficulty

src/rpcblockchain.cpp:29–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27int getBlockTimeByHeight(int nHeight);
28
29double GetDifficulty(const CBlockIndex* blockindex)
30{
31 // Floating point number that is a multiple of the minimum difficulty,
32 // minimum difficulty = 1.0.
33 if (blockindex == NULL) {
34 if (chainActive.Tip() == NULL)
35 return 1.0;
36 else
37 blockindex = chainActive.Tip();
38 }
39
40 int nShift = (blockindex->nBits >> 24) & 0xff;
41
42 double dDiff =
43 (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
44
45 while (nShift < 29) {
46 dDiff *= 256.0;
47 nShift++;
48 }
49 while (nShift > 29) {
50 dDiff /= 256.0;
51 nShift--;
52 }
53
54 return dDiff;
55}
56
57CBlockIndex* GetLastBlockOfType(const int nPoS) // 0: PoW; 1: PoS
58{

Callers 9

blockToJSONFunction · 0.85
getdifficultyFunction · 0.85
getblockchaininfoFunction · 0.85
GetPoWMHashPSFunction · 0.85
GetPoSKernelPSFunction · 0.85
getinfoFunction · 0.85
getstakingstatusFunction · 0.85
getmininginfoFunction · 0.85
BlockToStringFunction · 0.85

Calls 1

TipMethod · 0.80

Tested by

no test coverage detected