imports, indentation cleanup
authorforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Tue, 12 Jul 2011 12:38:44 +0000 (12:38 +0000)
committerforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Tue, 12 Jul 2011 12:38:44 +0000 (12:38 +0000)
git-svn-id: svn://forre.st/p2pool@1381 470744a7-cac9-478e-843e-5ec1b25c69e8

p2pool/bitcoin/data.py
p2pool/bitcoin/getwork.py
p2pool/bitcoin/p2p.py
p2pool/data.py
p2pool/worker_interface.py

index c06163c..53c77c4 100644 (file)
@@ -5,7 +5,7 @@ import hashlib
 import warnings
 
 from . import base58
-from p2pool.util import bases, expiring_dict, math
+from p2pool.util import bases, math
 
 class EarlyEnd(Exception):
     pass
@@ -65,7 +65,7 @@ class Type(object):
         data = self._pack(obj)
         
         assert self._unpack(data) == obj
-                
+        
         return data
     
     
@@ -74,7 +74,7 @@ class Type(object):
     
     def unpack_base58(self, base58_data):
         return self.unpack(base58.base58_decode(base58_data))
-        
+    
     
     def hash160(self, obj):
         return ShortHashType().unpack(hashlib.new('ripemd160', hashlib.sha256(self.pack(obj)).digest()).digest())
@@ -278,7 +278,7 @@ class FloatingIntegerType(Type):
     
     def truncate_to(self, x):
         return self._bits_to_target(self._target_to_bits(x, _check=False))
-        
+    
     def _bits_to_target(self, bits2):
         target = math.shift_left(bits2 & 0x00ffffff, 8 * ((bits2 >> 24) - 3))
         assert target == self._bits_to_target1(struct.pack("<I", bits2))
@@ -289,7 +289,7 @@ class FloatingIntegerType(Type):
         bits = bits[::-1]
         length = ord(bits[0])
         return bases.string_to_natural((bits[1:] + "\0"*length)[:length])
-
+    
     def _target_to_bits(self, target, _check=True):
         n = bases.natural_to_string(target)
         if n and ord(n[0]) >= 128:
index 322eaad..9173514 100644 (file)
@@ -4,8 +4,6 @@ Representation of a getwork request/reply
 
 from __future__ import division
 
-import struct
-
 from . import data as bitcoin_data
 from . import sha256
 
index 736ce41..a3020b7 100644 (file)
@@ -209,7 +209,7 @@ class Protocol(BaseProtocol):
         ('id', bitcoin_data.HashType()),
         ('order', bitcoin_data.FixedStrType(60)), # XXX
     ])
-
+    
     message_addr = bitcoin_data.ComposedType([
         ('addrs', bitcoin_data.ListType(bitcoin_data.ComposedType([
             ('timestamp', bitcoin_data.StructType('<I')),
@@ -251,11 +251,11 @@ class Protocol(BaseProtocol):
     def handle_reply(self, hash, reply, script):
         self.check_order.got_response(hash, dict(reply=reply, script=script))
         self.submit_order.got_response(hash, dict(reply=reply, script=script))
-
+    
     message_ping = bitcoin_data.ComposedType([])
     def handle_ping(self):
         pass
-
+    
     message_alert = bitcoin_data.ComposedType([
         ('message', bitcoin_data.VarStrType()),
         ('signature', bitcoin_data.VarStrType()),
index aa475c6..93f3db4 100644 (file)
@@ -200,7 +200,7 @@ def generate_transaction(tracker, previous_share_hash, new_script, subsidy, nonc
     previous_share2 = tracker.shares[previous_share_hash] if previous_share_hash is not None else None
     #previous_share2 = chain.shares
     #previous_shares
-    #shares = 
+    #shares =
     #shares = (previous_share2.shares if previous_share2 is not None else [net.SCRIPT]*net.SPREAD)[1:-1] + [new_script, new_script]
     
     lookbehind = 120
@@ -307,7 +307,7 @@ class OkayTracker(bitcoin_data.Tracker):
         Returns:
             {'result': 'okay', verified_height: ...} # if share has an okay parent or if share has CHAIN_LENGTH children and CHAIN_LENTH parents that it verified with
             {'result': 'needs_share', 'share_hash': ...} # if share doesn't have CHAIN_LENGTH parents
-            #{'result': 'needs_share_shares', 'share_hash': ...} # if share has CHAIN_LENGTH children and needs its shares to 
+            #{'result': 'needs_share_shares', 'share_hash': ...} # if share has CHAIN_LENGTH children and needs its shares to
             {'result': 'not_okay'} # if the share has a not okay parent or if the share has an okay parent and failed validation
         '''
         
index 3d849dc..3c389ee 100644 (file)
@@ -43,10 +43,10 @@ class WorkerInterface(jsonrpc.Server):
         self.putChild('', self)
     
     def rpc_getwork(self, data=None):
-      try:
-        if data is not None:
-            return self.response_callback(data)
-        
-        return self.compute(self.work.value)
-      except ValueError:
-        traceback.print_exc()
+        try:
+            if data is not None:
+                return self.response_callback(data)
+            
+            return self.compute(self.work.value)
+        except ValueError:
+            traceback.print_exc()