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
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']:
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])
#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))
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))
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]
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]