X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fdata.py;h=1d670f4c1aef7da7ebeaba0514433fde0e0a1892;hb=e245e385d481278a23a484e5492b80949be35547;hp=ba1cb7916e18870ebab678ee4c1f28af9c591082;hpb=6010d4d2008df26539aebfca9da44a0d1fc5254f;p=p2pool.git 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