From e245e385d481278a23a484e5492b80949be35547 Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sun, 28 Oct 2012 18:11:46 -0400 Subject: [PATCH] fixed punishing block solutions --- p2pool/data.py | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/p2pool/data.py b/p2pool/data.py index ba1cb79..1d670f4 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -275,12 +275,12 @@ class Share(object): return [] def should_punish_reason(self, previous_block, bits, tracker, known_txs): - if self.pow_hash <= self.header['bits'].target: - return -1, 'block solution' - if (self.header['previous_block'], self.header['bits']) != (previous_block, bits) and self.header_hash != previous_block and self.peer is not None: return True, 'Block-stale detected! %x < %x' % (self.header['previous_block'], previous_block) + if self.pow_hash <= self.header['bits'].target: + return -1, 'block solution' + return False, None def as_block(self, tracker, known_txs): @@ -546,12 +546,12 @@ class NewShare(object): return [known_txs[tx_hash] for tx_hash in other_tx_hashes] def should_punish_reason(self, previous_block, bits, tracker, known_txs): - if self.pow_hash <= self.header['bits'].target: - return -1, 'block solution' - if (self.header['previous_block'], self.header['bits']) != (previous_block, bits) and self.header_hash != previous_block and self.peer is not None: return True, 'Block-stale detected! %x < %x' % (self.header['previous_block'], previous_block) + if self.pow_hash <= self.header['bits'].target: + return -1, 'block solution' + other_txs = self._get_other_txs(tracker, known_txs) if other_txs is None: return True, 'not all txs present' @@ -713,7 +713,7 @@ class OkayTracker(forest.Tracker): if best is not None: best_share = self.items[best] punish, punish_reason = best_share.should_punish_reason(previous_block, bits, self, known_txs) - if punish: + if punish > 0: if p2pool.DEBUG: print >>sys.stderr, 'Punishing share for %r! Jumping from %s to %s!' % (punish_reason, format_hash(best), format_hash(best_share.previous_hash)) best = best_share.previous_hash -- 1.7.1