hide block not found error when not in debug mode
authorForrest Voight <forrest.voight@gmail.com>
Fri, 9 Mar 2012 02:31:03 +0000 (21:31 -0500)
committerForrest Voight <forrest.voight@gmail.com>
Fri, 9 Mar 2012 02:31:03 +0000 (21:31 -0500)
p2pool/main.py
p2pool/util/deferral.py

index 7157777..04aa1c0 100644 (file)
@@ -171,7 +171,12 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
             @deferral.DeferredCacher
             @defer.inlineCallbacks
             def height_cacher(block_hash):
-                x = yield bitcoind.rpc_getblock('%x' % (block_hash,))
+                try:
+                    x = yield bitcoind.rpc_getblock('%x' % (block_hash,))
+                except jsonrpc.Error, e:
+                    if e.code == -5 and not p2pool.DEBUG:
+                        raise deferral.RetrySilentlyException()
+                    raise
                 defer.returnValue(x['blockcount'] if 'blockcount' in x else x['height'])
             best_height_cached = variable.Variable((yield deferral.retry()(height_cacher)(pre_current_work.value['previous_block'])))
             def get_height_rel_highest(block_hash):
index 101d155..20f5ec8 100644 (file)
@@ -162,6 +162,8 @@ class DeferredCacher(object):
                 self.waiting.pop(key).callback(None)
             def eb(fail):
                 self.waiting.pop(key).callback(None)
+                if fail.check(RetrySilentlyException):
+                    return
                 print
                 print 'Error when requesting noncached value:'
                 fail.printTraceback()