From 3c4bf83c9fe8602c687afcd82d556cf58af4fbba Mon Sep 17 00:00:00 2001 From: m0mchil Date: Sun, 5 Feb 2012 12:29:17 +0200 Subject: [PATCH] Third time's the charm (fixed true target calculation from nBits) --- Transport.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Transport.py b/Transport.py index f8a4882..24b016c 100644 --- a/Transport.py +++ b/Transport.py @@ -89,10 +89,7 @@ def send_internal(self, result): def set_difficulty(self, difficulty): self.difficulty = difficulty - bits = hex(difficulty) - bits = bits[2:len(bits) - 1] - bits += ('0' * (8 - len(bits))) - bits = ''.join(list(chunks(bits, 2))[::-1]) + bits = '%08x' % difficulty.byteswap() true_target = '%064x' % (int(bits[2:], 16) * 2 ** (8 * (int(bits[:2], 16) - 3)),) true_target = ''.join(list(chunks(true_target, 2))[::-1]) self.true_target = np.array(unpack('IIIIIIII', true_target.decode('hex')), dtype=np.uint32)