From: Forrest Voight Date: Wed, 2 May 2012 04:55:52 +0000 (-0400) Subject: add warning to web interface X-Git-Tag: 0.11.0~12 X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=commitdiff_plain;h=1921933ead02b760112d2ab1d24fd3c7e7f5f904 add warning to web interface --- diff --git a/p2pool/data.py b/p2pool/data.py index 8db14c6..ef349cb 100644 --- a/p2pool/data.py +++ b/p2pool/data.py @@ -503,6 +503,19 @@ def get_desired_version_counts(tracker, best_share_hash, dist): res[share.desired_version] = res.get(share.desired_version, 0) + bitcoin_data.target_to_average_attempts(share.target) return res +def get_warnings(tracker, current_work): + res = [] + + height = tracker.get_height(current_work.value['best_share_hash']) + desired_version_counts = get_desired_version_counts(tracker, current_work.value['best_share_hash'], min(720, height)) + majority_desired_version = max(desired_version_counts, key=lambda k: desired_version_counts[k]) + if majority_desired_version not in [0, 1] and desired_version_counts[majority_desired_version] > sum(desired_version_counts.itervalues())/2: + res.append('A MAJORITY OF SHARES CONTAIN A VOTE FOR AN UNSUPPORTED SHARE IMPLEMENTATION! (v%i with %i%% support)\n' + 'An upgrade is likely necessary. Check http://p2pool.forre.st/ for more information.' % ( + majority_desired_version, 100*desired_version_counts[majority_desired_version]/sum(desired_version_counts.itervalues()))) + + return res + def format_hash(x): if x is None: return 'xxxxxxxx' diff --git a/p2pool/main.py b/p2pool/main.py index 923b147..ac74588 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -809,13 +809,9 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint): math.format_dt(2**256 / current_work.value['bits'].target / real_att_s), ) - desired_version_counts = p2pool_data.get_desired_version_counts(tracker, current_work.value['best_share_hash'], min(720, height)) - majority_desired_version = max(desired_version_counts, key=lambda k: desired_version_counts[k]) - if majority_desired_version not in [0, 1] and desired_version_counts[majority_desired_version] > sum(desired_version_counts.itervalues())/2: + for warning in p2pool_data.get_warnings(tracker, current_work): print >>sys.stderr, '#'*40 - print >>sys.stderr, '>>> WARNING: A MAJORITY OF SHARES CONTAIN A VOTE FOR AN UNSUPPORTED SHARE IMPLEMENTATION! (v%i with %i%% support)' % ( - majority_desired_version, 100*desired_version_counts[majority_desired_version]/sum(desired_version_counts.itervalues())) - print >>sys.stderr, '>>> An upgrade is likely necessary. Check http://p2pool.forre.st/ for more information.' + print >>sys.stderr, '>>> Warning: ' + warning print >>sys.stderr, '#'*40 if this_str != last_str or time.time() > last_time + 15: diff --git a/p2pool/web.py b/p2pool/web.py index 44d8ee3..2560eeb 100644 --- a/p2pool/web.py +++ b/p2pool/web.py @@ -172,6 +172,7 @@ def get_web_root(tracker, current_work, current_work2, get_current_txouts, datad ), uptime=time.time() - start_time, block_value=current_work2.value['subsidy']*1e-8, + warnings=p2pool_data.get_warnings(tracker, current_work), ) class WebInterface(resource.Resource): diff --git a/web-static/index.html b/web-static/index.html index 4a87612..be7f7be 100644 --- a/web-static/index.html +++ b/web-static/index.html @@ -31,6 +31,10 @@ d3.select('#efficiency').text(local_stats.efficiency != null ? d3.format('.4p')(local_stats.efficiency) : '???') d3.select('#uptime_days').text(d3.format('.3f')(local_stats.uptime / 60 / 60 / 24)); d3.select('#block_value').text(local_stats.block_value); + + d3.select('#warnings').selectAll().data(local_stats.warnings).enter().append('p') + .text(function(w){ return 'Warning: ' + w }) + .attr('style', 'color:red;border:1px solid red;padding:5px'); }); d3.json('/current_payouts', function(pays) { @@ -81,6 +85,7 @@

Shares: total ( orphaned, dead) Efficiency:

Payout if a block were found NOW: BTC to

Current block value: BTC

+

Share explorer

Best share: