style cleanup
[p2pool.git] / p2pool / p2p.py
index ef884fe..212e4c3 100644 (file)
@@ -2,9 +2,9 @@ from __future__ import division
 
 import random
 import time
-import traceback
 
 from twisted.internet import defer, protocol, reactor
+from twisted.python import log
 
 from p2pool.bitcoin import p2p as bitcoin_p2p
 from p2pool.bitcoin import data as bitcoin_data
@@ -211,7 +211,7 @@ class Protocol(bitcoin_p2p.BaseProtocol):
     message_share1bs = bitcoin_data.ComposedType([
         ('share1bs', bitcoin_data.ListType(p2pool_data.share1b_type)),
     ])
-    def handle_share1bs(self, share2s):
+    def handle_share1bs(self, share1bs):
         for share1b in share1bs:
             hash_ = bitcoin_data.block_header_type.hash256(share1b['header'])
             if not hash_ <= share1b['header']['target']:
@@ -224,7 +224,7 @@ class Protocol(bitcoin_p2p.BaseProtocol):
     
     def send_share(self, share, full=False):
         if share.hash <= share.header['target']:
-            self.send_share1bs(share2s=[share.as_share1b()])
+            self.send_share1bs(share1bs=[share.as_share1b()])
         else:
             if self.mode == 0 and not full:
                 self.send_share0s(hashes=[share.hash])
@@ -334,7 +334,7 @@ class Node(object):
                         #print 'Trying to connect to', host, port
                         reactor.connectTCP(host, port, ClientFactory(self), timeout=10)
             except:
-                traceback.print_exc()
+                log.err()
             
             yield deferral.sleep(random.expovariate(1/5))
     
@@ -345,7 +345,7 @@ class Node(object):
                 if len(self.addr_store) < self.preferred_addrs and self.peers:
                     random.choice(self.peers.values()).send_getaddrs(count=8)
             except:
-                traceback.print_exc()
+                log.err()
             
             yield deferral.sleep(random.expovariate(1/20))
     
@@ -370,7 +370,7 @@ class Node(object):
     def attempt_ended(self, connector):
         host, port = connector.getDestination().host, connector.getDestination().port
         if (host, port) not in self.attempts:
-            raise ValueError("don't have attempt")
+            raise ValueError('''don't have attempt''')
         if connector is not self.attempts[host, port]:
             raise ValueError('wrong connector')
         del self.attempts[host, port]
@@ -385,7 +385,7 @@ class Node(object):
     
     def lost_conn(self, conn):
         if conn.nonce not in self.peers:
-            raise ValueError("don't have peer")
+            raise ValueError('''don't have peer''')
         if conn is not self.peers[conn.nonce]:
             raise ValueError('wrong conn')
         del self.peers[conn.nonce]