expanded getblock height_cacher
authorForrest Voight <forrest.voight@gmail.com>
Fri, 9 Mar 2012 02:26:12 +0000 (21:26 -0500)
committerForrest Voight <forrest.voight@gmail.com>
Fri, 9 Mar 2012 02:26:43 +0000 (21:26 -0500)
p2pool/main.py

index 02d5e88..7157777 100644 (file)
@@ -168,7 +168,11 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
         yield set_real_work1()
         
         if '\ngetblock ' in (yield deferral.retry()(bitcoind.rpc_help)()):
-            height_cacher = deferral.DeferredCacher(defer.inlineCallbacks(lambda block_hash: defer.returnValue((lambda x: x['blockcount'] if 'blockcount' in x else x['height'])((yield bitcoind.rpc_getblock('%x' % (block_hash,)))))))
+            @deferral.DeferredCacher
+            @defer.inlineCallbacks
+            def height_cacher(block_hash):
+                x = yield bitcoind.rpc_getblock('%x' % (block_hash,))
+                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):
                 this_height = height_cacher.call_now(block_hash, 0)