MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / calc_difficulty

Method calc_difficulty

bitcoin/core/__init__.py:534–544  ·  view source on GitHub ↗

Calculate difficulty from nBits target

(nBits)

Source from the content-addressed store, hash-verified

532
533 @staticmethod
534 def calc_difficulty(nBits):
535 """Calculate difficulty from nBits target"""
536 nShift = (nBits >> 24) & 0xff
537 dDiff = float(0x0000ffff) / float(nBits & 0x00ffffff)
538 while nShift < 29:
539 dDiff *= 256.0
540 nShift += 1
541 while nShift > 29:
542 dDiff /= 256.0
543 nShift -= 1
544 return dDiff
545 difficulty = property(lambda self: CBlockHeader.calc_difficulty(self.nBits))
546
547 def __repr__(self):

Callers 2

CBlockHeaderClass · 0.80
TMethod · 0.80

Calls

no outgoing calls

Tested by 1

TMethod · 0.64