From 7e97e66c5a8c641a0402baa8a3f957c81f0c8653 Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sun, 18 Mar 2012 17:51:49 -0400 Subject: [PATCH] much-improved graphs --- p2pool/util/graph.py | 5 +- p2pool/web.py | 3 + web-static/graphs.html | 144 +++++++++++++++++++++++++++++------------------ 3 files changed, 95 insertions(+), 57 deletions(-) diff --git a/p2pool/util/graph.py b/p2pool/util/graph.py index 11f0412..2070163 100644 --- a/p2pool/util/graph.py +++ b/p2pool/util/graph.py @@ -46,9 +46,10 @@ class DataView(object): assert last_bin_end - self.desc.bin_width <= t <= last_bin_end return [( - last_bin_end - self.desc.bin_width*(i + 1/2), + (min(t, last_bin_end - self.desc.bin_width*i) + (last_bin_end - self.desc.bin_width*(i + 1)))/2, # center time (total/count if count else None) if self.ds_desc.source_is_cumulative - else total/(min(t, last_bin_end - self.desc.bin_width*i) - (last_bin_end - self.desc.bin_width*(i + 1))), + else total/(min(t, last_bin_end - self.desc.bin_width*i) - (last_bin_end - self.desc.bin_width*(i + 1))), # value + min(t, last_bin_end - self.desc.bin_width*i) - (last_bin_end - self.desc.bin_width*(i + 1)), # width ) for i, (total, count) in enumerate(bins)] diff --git a/p2pool/web.py b/p2pool/web.py index 65ba856..92758c6 100644 --- a/p2pool/web.py +++ b/p2pool/web.py @@ -347,12 +347,14 @@ def get_web_root(tracker, current_work, current_work2, get_current_txouts, datad 'last_day': graph.DataViewDescription(300, 60*60*24), 'last_week': graph.DataViewDescription(300, 60*60*24*7), 'last_month': graph.DataViewDescription(300, 60*60*24*30), + 'last_year': graph.DataViewDescription(300, 60*60*24*365.25), } hd = graph.HistoryDatabase.from_obj({ 'local_hash_rate': graph.DataStreamDescription(False, dataview_descriptions), 'local_dead_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), }, hd_obj) def _atomic_write(filename, data): open(filename + '.new', 'w').write(data) @@ -372,6 +374,7 @@ def get_web_root(tracker, current_work, current_work2, get_current_txouts, datad t = time.time() hd.datastreams['pool_rate'].add_datum(t, poolrate) hd.datastreams['pool_stale_rate'].add_datum(t, poolrate - nonstalerate) + hd.datastreams['current_payout'].add_datum(t, get_current_txouts().get(bitcoin_data.pubkey_hash_to_script2(my_pubkey_hash), 0)*1e-8) task.LoopingCall(add_point).start(5) new_root.putChild('graph_data', WebInterface(lambda source, view: json.dumps(hd.datastreams[source].dataviews[view].get_data(time.time())), 'application/json')) diff --git a/web-static/graphs.html b/web-static/graphs.html index e691929..b7963ba 100644 --- a/web-static/graphs.html +++ b/web-static/graphs.html @@ -38,76 +38,66 @@

P2Pool Graphs

-

Local rate - Blue=All, Red=Dead

+

Periods: Current:

-

Last hour

-
+

Local rate - Blue=All, Red=Dead (hash/second)

+ -

Last day

-
+

Current payout (BTC)

+ -

Last week

-
- -

Last month

-
- -

Pool rate - Blue=All, Red=Stale

- -

Last hour

-
- -

Last day

-
- -

Last week

-
- -

Last month

-
+

Pool rate - Blue=All, Red=Stale (hash/second)

+ -- 1.7.1