added graph of hash rate as estimated by shares found
authorForrest Voight <forrest@forre.st>
Thu, 22 Mar 2012 16:49:58 +0000 (12:49 -0400)
committerForrest Voight <forrest@forre.st>
Thu, 22 Mar 2012 20:06:46 +0000 (16:06 -0400)
p2pool/main.py
p2pool/web.py
web-static/graphs.html

index 99ceb9b..927315f 100644 (file)
@@ -441,6 +441,7 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
         
         
         pseudoshare_received = variable.Event()
+        share_received = variable.Event()
         local_rate_monitor = math.RateMonitor(10*60)
         
         class WorkerBridge(worker_interface.WorkerBridge):
@@ -667,6 +668,8 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
                                 shared_share_hashes.add(share.hash)
                         except:
                             log.err(None, 'Error forwarding block solution:')
+                        
+                        share_received.happened(bitcoin_data.target_to_average_attempts(share.target), not on_time)
                     
                     if pow_hash > target:
                         print 'Worker %s submitted share with hash > target:' % (request.getUser(),)
@@ -689,7 +692,7 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
         
         get_current_txouts = lambda: p2pool_data.get_expected_payouts(tracker, current_work.value['best_share_hash'], current_work.value['bits'].target, current_work2.value['subsidy'], net)
         
-        web_root = web.get_web_root(tracker, current_work, current_work2, get_current_txouts, datadir_path, net, get_stale_counts, my_pubkey_hash, local_rate_monitor, args.worker_fee, p2p_node, my_share_hashes, recent_blocks, pseudoshare_received)
+        web_root = web.get_web_root(tracker, current_work, current_work2, get_current_txouts, datadir_path, net, get_stale_counts, my_pubkey_hash, local_rate_monitor, args.worker_fee, p2p_node, my_share_hashes, recent_blocks, pseudoshare_received, share_received)
         worker_interface.WorkerInterface(WorkerBridge()).attach_to(web_root)
         
         deferral.retry('Error binding to worker port:', traceback=False)(reactor.listenTCP)(worker_endpoint[1], server.Site(web_root), interface=worker_endpoint[0])
index d6d33ec..b285e99 100644 (file)
@@ -44,7 +44,7 @@ def _atomic_write(filename, data):
         os.remove(filename)
         os.rename(filename + '.new', filename)
 
-def get_web_root(tracker, current_work, current_work2, get_current_txouts, datadir_path, net, get_stale_counts, my_pubkey_hash, local_rate_monitor, worker_fee, p2p_node, my_share_hashes, recent_blocks, pseudoshare_received):
+def get_web_root(tracker, current_work, current_work2, get_current_txouts, datadir_path, net, get_stale_counts, my_pubkey_hash, local_rate_monitor, worker_fee, p2p_node, my_share_hashes, recent_blocks, pseudoshare_received, share_received):
     start_time = time.time()
     
     web_root = resource.Resource()
@@ -392,6 +392,8 @@ def get_web_root(tracker, current_work, current_work2, get_current_txouts, datad
     hd = graph.HistoryDatabase.from_obj({
         'local_hash_rate': graph.DataStreamDescription(False, dataview_descriptions),
         'local_dead_hash_rate': graph.DataStreamDescription(False, dataview_descriptions),
+        'local_share_hash_rate': graph.DataStreamDescription(False, dataview_descriptions),
+        'local_dead_share_hash_rate': graph.DataStreamDescription(False, dataview_descriptions),
         'pool_rate': graph.DataStreamDescription(True, dataview_descriptions),
         'pool_stale_rate': graph.DataStreamDescription(True, dataview_descriptions),
         'current_payout': graph.DataStreamDescription(True, dataview_descriptions),
@@ -411,6 +413,12 @@ def get_web_root(tracker, current_work, current_work2, get_current_txouts, datad
             hd.datastreams['miner_hash_rates'].add_datum(t, {user: work})
             if dead:
                 hd.datastreams['miner_dead_hash_rates'].add_datum(t, {user: work})
+    @share_received.watch
+    def _(work, dead):
+        t = time.time()
+        hd.datastreams['local_share_hash_rate'].add_datum(t, work)
+        if dead:
+            hd.datastreams['local_dead_share_hash_rate'].add_datum(t, work)
     def add_point():
         if tracker.get_height(current_work.value['best_share_hash']) < 720:
             return
index 649b3fb..63d431a 100644 (file)
@@ -36,6 +36,9 @@
         <h2>Local rate - Blue=All, Red=Dead (hash/second)</h2>
         <svg id="local"></svg>
         
+        <h2>Local rate reflected in shares - Blue=All, Red=Dead (hash/second)</h2>
+        <svg id="local_shares"></svg>
+        
         <h2>Current payout (BTC)</h2>
         <svg id="payout"></svg>
         
                     {"data": getData("/web/graph_data/local_hash_rate/last_" + lowerperiod), "value_getter": identity, "color": "#0000FF"},
                     {"data": getData("/web/graph_data/local_dead_hash_rate/last_" + lowerperiod), "value_getter": identity, "color": "#FF0000"}
                 ]);
+                plot(d3.select("#local_shares"), [
+                    {"data": getData("/web/graph_data/local_share_hash_rate/last_" + lowerperiod), "value_getter": identity, "color": "#0000FF"},
+                    {"data": getData("/web/graph_data/local_dead_share_hash_rate/last_" + lowerperiod), "value_getter": identity, "color": "#FF0000"}
+                ]);
                 plot(d3.select("#payout"), [
                     {"data": getData("/web/graph_data/current_payout/last_" + lowerperiod), "value_getter": identity, "color": "#0000FF"}
                 ]);