retry RPC help and initial RPC getblock if they fail
authorForrest Voight <forrest.voight@gmail.com>
Sun, 12 Feb 2012 18:25:02 +0000 (13:25 -0500)
committerForrest Voight <forrest.voight@gmail.com>
Sun, 12 Feb 2012 18:25:02 +0000 (13:25 -0500)
p2pool/main.py
p2pool/util/deferral.py

index ed311ac..9942010 100644 (file)
@@ -175,9 +175,9 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
             ))
         yield set_real_work1()
         
-        if '\ngetblock ' in (yield bitcoind.rpc_help()):
+        if '\ngetblock ' in (yield deferral.retry()(bitcoind.rpc_help)()):
             height_cacher = deferral.DeferredCacher(defer.inlineCallbacks(lambda block_hash: defer.returnValue((yield bitcoind.rpc_getblock('%x' % (block_hash,)))['blockcount'])))
-            best_height_cached = variable.Variable((yield height_cacher(pre_current_work.value['previous_block'])))
+            best_height_cached = variable.Variable((yield deferral.retry()(height_cacher)(pre_current_work.value['previous_block'])))
             def get_height_rel_highest(block_hash):
                 this_height = height_cacher.call_now(block_hash, 0)
                 best_height = height_cacher.call_now(pre_current_work.value['previous_block'], 0)
index 072d559..868649b 100644 (file)
@@ -13,7 +13,7 @@ def sleep(t):
 class RetrySilentlyException(Exception):
     pass
 
-def retry(message, delay, max_retries=None):
+def retry(message='Error:', delay=3, max_retries=None):
     '''
     @retry('Error getting block:', 1)
     @defer.inlineCallbacks