From: Forrest Voight Date: Sun, 12 Feb 2012 18:25:02 +0000 (-0500) Subject: retry RPC help and initial RPC getblock if they fail X-Git-Tag: 0.8.6~17 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=9e52f7840ea4bef85b3363478079faa7a43d9811;p=p2pool.git retry RPC help and initial RPC getblock if they fail --- diff --git a/p2pool/main.py b/p2pool/main.py index ed311ac..9942010 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -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) diff --git a/p2pool/util/deferral.py b/p2pool/util/deferral.py index 072d559..868649b 100644 --- a/p2pool/util/deferral.py +++ b/p2pool/util/deferral.py @@ -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