retry block submittal
authorForrest Voight <forrest@forre.st>
Fri, 10 Feb 2012 19:21:42 +0000 (14:21 -0500)
committerForrest Voight <forrest@forre.st>
Fri, 10 Feb 2012 19:21:42 +0000 (14:21 -0500)
p2pool/main.py

index 73881de..6265af4 100644 (file)
@@ -552,10 +552,13 @@ def main(args, net, datadir_path, merged_urls):
                     
                     try:
                         if pow_hash <= header['bits'].target or p2pool.DEBUG:
-                            if factory.conn.value is not None:
+                            @deferral.retry('Error submitting primary block: (will retry)', 10, 10)
+                            def submit_block():
+                                if factory.conn.value is None:
+                                    print >>sys.stderr, 'No bitcoind connection when block submittal attempted! Hash: %x' % (bitcoin_data.hash256(bitcoin_data.block_header_type.pack(header)),)
+                                    raise deferral.RetrySilentlyException()
                                 factory.conn.value.send_block(block=dict(header=header, txs=transactions))
-                            else:
-                                print >>sys.stderr, 'No bitcoind connection when block submittal attempted! Erp!'
+                            submit_block()
                             if pow_hash <= header['bits'].target:
                                 print
                                 print 'GOT BLOCK FROM MINER! Passing to bitcoind! bitcoin: %x' % (bitcoin_data.hash256(bitcoin_data.block_header_type.pack(header)),)