X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fdata.py;h=e8fe347cc20232990f97ef61795def710a88e94a;hb=39767a2c7da3b22efc8d90623dcda12b6ab4f419;hp=3ebc1f7d609616c1d89f8bbf2c7770d06721daf6;hpb=0e5547d07973eebb9c82caf195031dff05857398;p=p2pool.git diff --git a/p2pool/data.py b/p2pool/data.py index 3ebc1f7..e8fe347 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -430,7 +430,7 @@ class OkayTracker(forest.Tracker): try: share.check(self) except: - log.err(None, 'Share check failed:') + log.err(None, 'Share check failed: %064x -> %064x' % (share.hash, share.previous_hash if share.previous_hash is not None else 0)) return False else: self.verified.add(share) @@ -438,21 +438,21 @@ class OkayTracker(forest.Tracker): def think(self, block_rel_height_func, previous_block, bits, known_txs): desired = set() + bad_peer_addresses = set() # O(len(self.heads)) # make 'unverified heads' set? # for each overall head, attempt verification # if it fails, attempt on parent, and repeat # if no successful verification because of lack of parents, request parent - bads = set() + bads = [] for head in set(self.heads) - set(self.verified.heads): head_height, last = self.get_height_and_last(head) for share in self.get_chain(head, head_height if last is None else min(5, max(0, head_height - self.net.CHAIN_LENGTH))): if self.attempt_verify(share): break - if share.hash in self.heads: - bads.add(share.hash) + bads.append(share.hash) else: if last is not None: desired.add(( @@ -463,10 +463,16 @@ class OkayTracker(forest.Tracker): )) for bad in bads: assert bad not in self.verified.items - assert bad in self.heads + #assert bad in self.heads + bad_share = self.items[bad] + if bad_share.peer_addr is not None: + bad_peer_addresses.add(bad_share.peer_addr) if p2pool.DEBUG: print "BAD", bad - self.remove(bad) + try: + self.remove(bad) + except NotImplementedError: + pass # try to get at least CHAIN_LENGTH height for each verified head, requesting parents if needed for head in list(self.verified.heads): @@ -527,7 +533,7 @@ class OkayTracker(forest.Tracker): for peer_addr, hash, ts, targ in desired: print ' ', None if peer_addr is None else '%s:%i' % peer_addr, format_hash(hash), math.format_dt(time.time() - ts), bitcoin_data.target_to_difficulty(targ), ts >= timestamp_cutoff, targ <= target_cutoff - return best, [(peer_addr, hash) for peer_addr, hash, ts, targ in desired if ts >= timestamp_cutoff], decorated_heads + return best, [(peer_addr, hash) for peer_addr, hash, ts, targ in desired if ts >= timestamp_cutoff], decorated_heads, bad_peer_addresses def score(self, share_hash, block_rel_height_func): # returns approximate lower bound on chain's hashrate in the last self.net.CHAIN_LENGTH*15//16*self.net.SHARE_PERIOD time