fixed network issue, added memory profiler
authorforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Thu, 16 Jun 2011 15:01:42 +0000 (15:01 +0000)
committerforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Thu, 16 Jun 2011 15:01:42 +0000 (15:01 +0000)
git-svn-id: svn://forre.st/p2pool@1342 470744a7-cac9-478e-843e-5ec1b25c69e8

main.py
p2p.py
p2pool.py

diff --git a/main.py b/main.py
index bfeb8f9..5df5ddf 100644 (file)
--- a/main.py
+++ b/main.py
@@ -158,6 +158,16 @@ def main(args):
         print '    Payout script:', my_script.encode('hex')
         print
         
+        @repr
+        @apply
+        @defer.inlineCallbacks
+        def mem():
+            while True:
+                yield util.sleep(300)
+                from guppy import hpy
+                h = hpy()
+                print h.heap()
+        
         @defer.inlineCallbacks
         def real_get_block(block_hash):
             block = yield (yield factory.getProtocol()).get_block(block_hash)
@@ -165,7 +175,7 @@ def main(args):
             defer.returnValue(block)
         get_block = util.DeferredCacher(real_get_block, expiring_dict.ExpiringDict(3600))
         
-        chains = expiring_dict.ExpiringDict(1000)
+        chains = expiring_dict.ExpiringDict(300)
         def get_chain(chain_id_data):
             return chains.setdefault(chain_id_data, Chain(chain_id_data))
         # information affecting work that should trigger a long-polling update
@@ -346,7 +356,7 @@ def main(args):
         
         # setup worker logic
         
-        merkle_root_to_transactions = expiring_dict.ExpiringDict(1000)
+        merkle_root_to_transactions = expiring_dict.ExpiringDict(300)
         
         def compute(state):
             generate_txn, shares = p2pool.generate_transaction(
diff --git a/p2p.py b/p2p.py
index ffc31c0..4014d5e 100644 (file)
--- a/p2p.py
+++ b/p2p.py
@@ -146,9 +146,6 @@ class Protocol(bitcoin_p2p.BaseProtocol):
         
         self.node_var_watch = self.node.mode_var.changed.watch(lambda new_mode: self.send_set_mode(mode=new_mode))
         
-        self._think()
-        self._think2()
-        
         reactor.callLater(10, self._connect_timeout)
     
     def _connect_timeout(self):
@@ -187,6 +184,9 @@ class Protocol(bitcoin_p2p.BaseProtocol):
         self.connected2 = True
         self.node.got_conn(self)
         
+        self._think()
+        self._think2()
+        
         if state['highest']['hash'] != 2**256 - 1:
             self.handle_share0s(chains=[dict(
                 chain_id=state['chain_id'],
index b9a8a4a..c417a6b 100644 (file)
--- a/p2pool.py
+++ b/p2pool.py
@@ -121,7 +121,7 @@ class Share2(object):
     
     def __init__(self, share, chain, shares, height):
         self.share = share
-        self.shares = shares
+        self.shares = map(intern, shares)
         self.height = height
         self.chain = chain
         self.shared = False