From: Forrest Voight Date: Sat, 10 Dec 2011 04:13:34 +0000 (-0500) Subject: style and import fixes X-Git-Tag: 0.8.2~143^2 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=a6be63503c3a272de47c59fb883b35b20ed8b88f;p=p2pool.git style and import fixes --- diff --git a/p2pool/bitcoin/p2p.py b/p2pool/bitcoin/p2p.py index e3b7e8e..cc72159 100644 --- a/p2pool/bitcoin/p2p.py +++ b/p2pool/bitcoin/p2p.py @@ -367,7 +367,7 @@ class HeightTracker(object): if last not in self._tracker.tails: return -1e300 return height - max(self._tracker.get_height(head_hash) for head_hash in self._tracker.tails[last]) - + def stop(self): self._factory.new_headers.unwatch(self._watch1) self._factory.new_block.unwatch(self._watch2) diff --git a/p2pool/p2p.py b/p2pool/p2p.py index 0c64188..5dd6441 100644 --- a/p2pool/p2p.py +++ b/p2pool/p2p.py @@ -10,7 +10,7 @@ import p2pool from p2pool import data as p2pool_data from p2pool.bitcoin import p2p as bitcoin_p2p from p2pool.bitcoin import data as bitcoin_data -from p2pool.util import deferral, dicts +from p2pool.util import deferral class Protocol(bitcoin_p2p.BaseProtocol): version = 2 diff --git a/p2pool/test/bitcoin/test_sha256.py b/p2pool/test/bitcoin/test_sha256.py index 16d3238..2d37bef 100644 --- a/p2pool/test/bitcoin/test_sha256.py +++ b/p2pool/test/bitcoin/test_sha256.py @@ -27,12 +27,12 @@ class Test(unittest.TestCase): for i in xrange(100): test = random_str(int(random.expovariate(1/100))) test2 = random_str(int(random.expovariate(1/100))) - + a = sha256.sha256(test) a = a.copy() a.update(test2) a = a.hexdigest() - + b = hashlib.sha256(test) b = b.copy() b.update(test2) diff --git a/p2pool/test/util/test_forest.py b/p2pool/test/util/test_forest.py index 8f70de0..8b6453c 100644 --- a/p2pool/test/util/test_forest.py +++ b/p2pool/test/util/test_forest.py @@ -77,7 +77,7 @@ class FakeShare(object): def test_tracker(self): t = DumbTracker(self.shares.itervalues()) - + assert self.shares == t.shares, (self.shares, t.shares) assert self.reverse_shares == t.reverse_shares, (self.reverse_shares, t.reverse_shares) assert self.heads == t.heads, (self.heads, t.heads) @@ -104,10 +104,10 @@ def generate_tracker_random(n): class Test(unittest.TestCase): def test_tracker(self): t = generate_tracker_simple(1000) - + assert t.heads == {999: None} assert t.tails == {None: set([999])} - + assert t.get_nth_parent_hash(900, 500) == 900 - 500 assert t.get_nth_parent_hash(901, 42) == 901 - 42 diff --git a/p2pool/util/math.py b/p2pool/util/math.py index efc4741..6eb8303 100644 --- a/p2pool/util/math.py +++ b/p2pool/util/math.py @@ -75,10 +75,10 @@ def perfect_round(x): def erf(x): # save the sign of x sign = 1 - if x < 0: + if x < 0: sign = -1 x = abs(x) - + # constants a1 = 0.254829592 a2 = -0.284496736 @@ -86,7 +86,7 @@ def erf(x): a4 = -1.453152027 a5 = 1.061405429 p = 0.3275911 - + # A&S formula 7.1.26 t = 1.0/(1.0 + p*x) y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*math.exp(-x*x)