| 27 | int getBlockTimeByHeight(int nHeight); |
| 28 | |
| 29 | double 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 | |
| 57 | CBlockIndex* GetLastBlockOfType(const int nPoS) // 0: PoW; 1: PoS |
| 58 | { |
no test coverage detected