def getDifficult(bits):
step0 = getBigEndian(bits)
step1 = "0x"+step0
step2 = BitArray(step1)
step3 = step2.hex
first_pair ="0x" + step3[:2]
firstPair = BitArray(first_pair)
second_pair ="0x" + step3[2:8]
secondPair = BitArray(second_pair)
firstPairVal = firstPair.int
secondPairVal = secondPair.int
formula = 2**(8*(firstPairVal -3))
bitsDec = secondPairVal * formula
highestDifficulty = BitArray("0x00000000FFFF0000000000000000000000000000000000000000000000000000")
highDiffDec = highestDifficulty.int
answer = float(highDiffDec/bitsDec)
return answer
评论列表
文章目录