Skip to content

Commit

Permalink
Third time's the charm (fixed true target calculation from nBits)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0mchil committed Feb 5, 2012
1 parent 4871f06 commit 3c4bf83
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Transport.py
Expand Up @@ -89,10 +89,7 @@ def send_internal(self, result):


def set_difficulty(self, difficulty): def set_difficulty(self, difficulty):
self.difficulty = difficulty self.difficulty = difficulty
bits = hex(difficulty) bits = '%08x' % difficulty.byteswap()
bits = bits[2:len(bits) - 1]
bits += ('0' * (8 - len(bits)))
bits = ''.join(list(chunks(bits, 2))[::-1])
true_target = '%064x' % (int(bits[2:], 16) * 2 ** (8 * (int(bits[:2], 16) - 3)),) true_target = '%064x' % (int(bits[2:], 16) * 2 ** (8 * (int(bits[:2], 16) - 3)),)
true_target = ''.join(list(chunks(true_target, 2))[::-1]) true_target = ''.join(list(chunks(true_target, 2))[::-1])
self.true_target = np.array(unpack('IIIIIIII', true_target.decode('hex')), dtype=np.uint32) self.true_target = np.array(unpack('IIIIIIII', true_target.decode('hex')), dtype=np.uint32)
Expand Down

0 comments on commit 3c4bf83

Please sign in to comment.