From: Forrest Voight Date: Wed, 9 May 2012 00:03:24 +0000 (-0400) Subject: fixed getwork failing if miners idle long enough to let local hash rate fall to 0 X-Git-Tag: 0.11.2~16 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=f1fb4cf10670960d3bfbf91873dc04bc1cb306c8 fixed getwork failing if miners idle long enough to let local hash rate fall to 0 --- diff --git a/p2pool/main.py b/p2pool/main.py index 7d5e396..c6994c4 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -561,11 +561,11 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint): ) if desired_pseudoshare_target is None: + target = 2**256-1 if len(self.recent_shares_ts_work) == 50: hash_rate = sum(work for ts, work in self.recent_shares_ts_work[1:])//(self.recent_shares_ts_work[-1][0] - self.recent_shares_ts_work[0][0]) - target = min(2**256-1, int(4*2**256/hash_rate)) - else: - target = 2**256-1 + if hash_rate: + target = min(target, int(4*2**256/hash_rate)) else: target = desired_pseudoshare_target target = max(target, share_info['bits'].target)