display current version on web
authorForrest Voight <forrest@forre.st>
Thu, 14 Jun 2012 22:49:36 +0000 (18:49 -0400)
committerForrest Voight <forrest@forre.st>
Thu, 14 Jun 2012 22:53:49 +0000 (18:53 -0400)
p2pool/main.py
p2pool/web.py
web-static/index.html

index fc7f949..6db558a 100644 (file)
@@ -38,10 +38,14 @@ def getwork(bitcoind):
             raise deferral.RetrySilentlyException()
         raise
     packed_transactions = [x.decode('hex') for x in work['transactions']]
+    s = time.time()
+    unpacked = map(bitcoin_data.tx_type.unpack, packed_transactions)
+    e = time.time()
+    print (e-s)*1000, "ms"
     defer.returnValue(dict(
         version=work['version'],
         previous_block_hash=int(work['previousblockhash'], 16),
-        transactions=map(bitcoin_data.tx_type.unpack, packed_transactions),
+        transactions=unpacked,
         merkle_link=bitcoin_data.calculate_merkle_link([0] + map(bitcoin_data.hash256, packed_transactions), 0), # using 0 is a bit of a hack, but will always work when index=0
         subsidy=work['coinbasevalue'],
         time=work['time'],
index 9dfb926..0205c52 100644 (file)
@@ -10,6 +10,7 @@ from twisted.internet import task
 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 graph, math
@@ -302,6 +303,7 @@ def get_web_root(tracker, current_work, get_current_txouts, datadir_path, net, g
         block_explorer_url_prefix=net.PARENT.BLOCK_EXPLORER_URL_PREFIX,
         address_explorer_url_prefix=net.PARENT.ADDRESS_EXPLORER_URL_PREFIX,
     )))
+    new_root.putChild('version', WebInterface(lambda: p2pool.__version__))
     
     hd_path = os.path.join(datadir_path, 'graph_db')
     hd_data = _atomic_read(hd_path)
index 7314326..e37d732 100644 (file)
@@ -38,6 +38,9 @@
                     .attr('style', 'color:red;border:1px solid red;padding:5px');
             });
             
+            d3.json('/web/version', function(version) {
+                d3.selectAll('#version').text(version);
+            });
             
             d3.json('/web/currency_info', function(currency_info) {
                 d3.selectAll('.symbol').text(currency_info.symbol);
@@ -85,6 +88,7 @@
     <body>
         <h1>P2Pool</h1>
         <p><a href="graphs.html">Graphs</a></p>
+        <p>Version: <span id="version"></span></p>
         <p>Pool rate: <span id="pool_rate"></span> (<span id="pool_stale"></span> stale) Share difficulty: <span id="difficulty"></span></p>
         <p>Node uptime: <span id="uptime_days"></span> days Peers: <span id="peers_out"></span> out, <span id="peers_in"></span> in</p>
         <p>Local rate: <span id="local_rate"></span> (<span id="local_doa"></span> DOA)</p>