From 64a42eb327e684ae702cc82bd8d8de1239a328c0 Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Tue, 17 Jan 2012 13:19:20 -0500 Subject: [PATCH] changed handling of addr_store --- p2pool/main.py | 8 ++++---- p2pool/p2p.py | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/p2pool/main.py b/p2pool/main.py index 2f2db68..11d8b84 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -307,10 +307,6 @@ def main(args, net, datadir_path): except: print >>sys.stderr, "error reading addrs" - def save_addrs(): - open(os.path.join(datadir_path, 'addrs.txt'), 'w').writelines(repr(x) + '\n' for x in addrs.iteritems()) - task.LoopingCall(save_addrs).start(60) - p2p_node = p2p.Node( best_share_hash_func=lambda: current_work.value['best_share_hash'], port=args.p2pool_port, @@ -324,6 +320,10 @@ def main(args, net, datadir_path): p2p_node.start() + def save_addrs(): + open(os.path.join(datadir_path, 'addrs.txt'), 'w').writelines(repr(x) + '\n' for x in p2p_node.addr_store.iteritems()) + task.LoopingCall(save_addrs).start(60) + # send share when the chain changes to their chain def work_changed(new_work): #print 'Work changed:', new_work diff --git a/p2pool/p2p.py b/p2pool/p2p.py index 632ba4d..0a67683 100644 --- a/p2pool/p2p.py +++ b/p2pool/p2p.py @@ -261,14 +261,11 @@ class ClientFactory(protocol.ClientFactory): self.node.attempt_ended(connector) class Node(object): - def __init__(self, best_share_hash_func, port, net, addr_store=None, preferred_addrs=set(), desired_peers=10, max_conns=50, max_attempts=30, preferred_storage=1000): - if addr_store is None: - addr_store = {} - + def __init__(self, best_share_hash_func, port, net, addr_store={}, preferred_addrs=set(), desired_outgoing=10, max_outgoing_attempts=30, max_incomming=50, preferred_storage=1000): self.best_share_hash_func = best_share_hash_func self.port = port self.net = net - self.addr_store = addr_store + self.addr_store = dict(addr_store) self.preferred_addrs = preferred_addrs self.desired_peers = desired_peers self.max_conns = max_conns -- 1.7.1