changed handling of addr_store
authorForrest Voight <forrest@forre.st>
Tue, 17 Jan 2012 18:19:20 +0000 (13:19 -0500)
committerForrest Voight <forrest@forre.st>
Tue, 17 Jan 2012 18:19:20 +0000 (13:19 -0500)
p2pool/main.py
p2pool/p2p.py

index 2f2db68..11d8b84 100644 (file)
@@ -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
index 632ba4d..0a67683 100644 (file)
@@ -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