fixed getwork failing if miners idle long enough to let local hash rate fall to 0
authorForrest Voight <forrest.voight@gmail.com>
Wed, 9 May 2012 00:03:24 +0000 (20:03 -0400)
committerForrest Voight <forrest.voight@gmail.com>
Wed, 9 May 2012 02:06:25 +0000 (22:06 -0400)
p2pool/main.py

index 7d5e396..c6994c4 100644 (file)
@@ -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)