X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=p2pool%2Fweb.py;h=238e823a209062255a46fea76dcc1d5fb0b63367;hb=0460c6cf03b8da4a5accb5ac26606e596a5571ff;hp=b7d80b46f90c83592c124349868455497fcc25e0;hpb=0a3493d6873cfef4fb189d39e64dfbc6e162e2a7;p=p2pool.git diff --git a/p2pool/web.py b/p2pool/web.py index b7d80b4..238e823 100644 --- a/p2pool/web.py +++ b/p2pool/web.py @@ -7,13 +7,13 @@ import sys import time import traceback -from twisted.internet import defer +from twisted.internet import defer, reactor 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 . import data as p2pool_data, p2p from util import deferral, deferred_resource, graph, math, memory, pack, variable def _atomic_read(filename): @@ -45,7 +45,7 @@ def _atomic_write(filename, data): os.remove(filename) os.rename(filename + '.new', filename) -def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Event()): +def get_web_root(wb, datadir_path, bitcoind_getinfo_var, stop_event=variable.Event()): node = wb.node start_time = time.time() @@ -167,8 +167,11 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve attempts_to_share=bitcoin_data.target_to_average_attempts(node.tracker.items[node.best_share_var.value].max_target), attempts_to_block=bitcoin_data.target_to_average_attempts(node.bitcoind_work.value['bits'].target), 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), + warnings=p2pool_data.get_warnings(node.tracker, node.best_share_var.value, node.net, bitcoind_getinfo_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): @@ -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__)) @@ -371,6 +376,7 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve 'local_dead_hash_rate': graph.DataStreamDescription(dataview_descriptions, is_gauge=False), 'local_share_hash_rate': graph.DataStreamDescription(dataview_descriptions, is_gauge=False), 'local_dead_share_hash_rate': graph.DataStreamDescription(dataview_descriptions, is_gauge=False), + 'local_orphan_share_hash_rate': graph.DataStreamDescription(dataview_descriptions, is_gauge=False), 'pool_rates': graph.DataStreamDescription(dataview_descriptions, multivalues=True, multivalue_undefined_means_0=True), 'current_payout': graph.DataStreamDescription(dataview_descriptions), @@ -401,11 +407,21 @@ def get_web_root(wb, datadir_path, bitcoind_warning_var, stop_event=variable.Eve if dead: hd.datastreams['miner_dead_hash_rates'].add_datum(t, {user: work}) @wb.share_received.watch - def _(work, dead): + def _(work, dead, share_hash): 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 later(): + res = node.tracker.is_child_of(share_hash, node.best_share_var.value) + if res is None: return # share isn't connected to sharechain? + if res and dead: # share was DOA, but is now in sharechain + # remove from DOA graph + hd.datastreams['local_dead_share_hash_rate'].add_datum(t, -work) + elif not res and not dead: # share wasn't DOA, and isn't in sharechain + # add to orphan graph + hd.datastreams['local_orphan_share_hash_rate'].add_datum(t, work) + reactor.callLater(200, later) @node.p2p_node.traffic_happened.watch def _(name, bytes): hd.datastreams['traffic_rate'].add_datum(time.time(), {name: bytes})