warn user about bitcoin connection slots if p2p connect takes longer than 5 seconds
[p2pool.git] / p2pool / web.py
index 6b9f575..bac76f9 100644 (file)
@@ -7,14 +7,14 @@ import sys
 import time
 import traceback
 
-from twisted.internet import defer, task
+from twisted.internet import defer
 from twisted.python import log
 from twisted.web import resource, static
 
 import p2pool
 from bitcoin import data as bitcoin_data
-from . import data as p2pool_data
-from util import deferred_resource, graph, math, memory, pack, variable
+from . import data as p2pool_data, p2p
+from util import deferral, deferred_resource, graph, math, memory, pack, variable
 
 def _atomic_read(filename):
     try:
@@ -169,6 +169,9 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve
             block_value=node.bitcoind_work.value['subsidy']*1e-8,
             warnings=p2pool_data.get_warnings(node.tracker, node.best_share_var.value, node.net, bitcoind_warning_var.value, node.bitcoind_work.value),
             donation_proportion=wb.donation_percentage/100,
+            version=p2pool.__version__,
+            protocol_version=p2p.Protocol.VERSION,
+            fee=wb.worker_fee,
         )
     
     class WebInterface(deferred_resource.DeferredResource):
@@ -264,7 +267,7 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve
         
         with open(os.path.join(datadir_path, 'stats'), 'wb') as f:
             f.write(json.dumps(stat_log))
-    x = task.LoopingCall(update_stat_log)
+    x = deferral.RobustLoopingCall(update_stat_log)
     x.start(5*60)
     stop_event.watch(x.stop)
     new_root.putChild('log', WebInterface(lambda: stat_log))
@@ -309,8 +312,9 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve
                     hash='%064x' % share.gentx_hash,
                     coinbase=share.share_data['coinbase'].ljust(2, '\x00').encode('hex'),
                     value=share.share_data['subsidy']*1e-8,
+                    last_txout_nonce='%016x' % share.contents['last_txout_nonce'],
                 ),
-                txn_count=len(list(share.iter_transaction_hash_refs())),
+                other_transaction_hashes=['%064x' % x for x in share.get_other_tx_hashes(node.tracker)],
             ),
         )
     new_root.putChild('share', WebInterface(lambda share_hash_str: get_share(share_hash_str)))
@@ -329,6 +333,7 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve
         symbol=node.net.PARENT.SYMBOL,
         block_explorer_url_prefix=node.net.PARENT.BLOCK_EXPLORER_URL_PREFIX,
         address_explorer_url_prefix=node.net.PARENT.ADDRESS_EXPLORER_URL_PREFIX,
+        tx_explorer_url_prefix=node.net.PARENT.TX_EXPLORER_URL_PREFIX,
     )))
     new_root.putChild('version', WebInterface(lambda: p2pool.__version__))
     
@@ -387,7 +392,7 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve
         'getwork_latency': graph.DataStreamDescription(dataview_descriptions),
         'memory_usage': graph.DataStreamDescription(dataview_descriptions),
     }, hd_obj)
-    x = task.LoopingCall(lambda: _atomic_write(hd_path, json.dumps(hd.to_obj())))
+    x = deferral.RobustLoopingCall(lambda: _atomic_write(hd_path, json.dumps(hd.to_obj())))
     x.start(100)
     stop_event.watch(x.stop)
     @wb.pseudoshare_received.watch
@@ -437,7 +442,7 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve
         except:
             if p2pool.DEBUG:
                 traceback.print_exc()
-    x = task.LoopingCall(add_point)
+    x = deferral.RobustLoopingCall(add_point)
     x.start(5)
     stop_event.watch(x.stop)
     @node.bitcoind_work.changed.watch