Skip to content

Commit

Permalink
include txs in share explorer (and other share explorer improvements)
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestv committed Aug 20, 2013
1 parent 6dc8cdb commit 2872302
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
8 changes: 8 additions & 0 deletions p2pool/bitcoin/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='https://blockchain.info/block/',
ADDRESS_EXPLORER_URL_PREFIX='https://blockchain.info/address/',
TX_EXPLORER_URL_PREFIX='https://blockchain.info/tx/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=0.001e8,
Expand All @@ -43,6 +44,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
TX_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/tx/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=1e8,
Expand All @@ -64,6 +66,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
TX_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/tx/',
SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=0.2e8,
Expand All @@ -84,6 +87,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
TX_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/tx/',
SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=1e8,
Expand All @@ -105,6 +109,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/address/',
TX_EXPLORER_URL_PREFIX='http://explorer.litecoin.net/tx/',
SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
DUMB_SCRYPT_DIFF=2**16,
DUST_THRESHOLD=0.03e8,
Expand All @@ -125,6 +130,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
TX_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/tx/',
SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256 - 1),
DUMB_SCRYPT_DIFF=2**16,
DUST_THRESHOLD=1e8,
Expand All @@ -146,6 +152,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Terracoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Terracoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.terracoin'), 'terracoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/address/',
TX_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/tx/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=1e8,
Expand All @@ -166,6 +173,7 @@
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Terracoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Terracoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.terracoin'), 'terracoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/address/',
TX_EXPLORER_URL_PREFIX='http://cryptocoinexplorer.com:3750/testnet/tx/',
SANE_TARGET_RANGE=(2**256//2**32//1000 - 1, 2**256//2**32 - 1),
DUMB_SCRYPT_DIFF=1,
DUST_THRESHOLD=1e8,
Expand Down
4 changes: 3 additions & 1 deletion p2pool/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ def get_share(share_hash_str):
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)))
Expand All @@ -332,6 +333,7 @@ def get_share_data(share_hash_str):
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__))

Expand Down
4 changes: 2 additions & 2 deletions web-static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

d3.json('/current_payouts', function(pays) {
d3.json('/payout_addr', function(addr) {
d3.select('#payout_addr').text(addr);
d3.select('#payout_addr').text(addr).attr('href', currency_info.address_explorer_url_prefix + addr);
d3.select('#payout_amount').text(addr in pays ? pays[addr] : 0);
});

Expand Down Expand Up @@ -104,7 +104,7 @@ <h1>P2Pool <span class="symbol"></span></h1>
<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) Expected time to share: <span id="time_to_share"></span></p>
<p>Shares: <span id="shares_total"></span> total (<span id="shares_orphan"></span> orphaned, <span id="shares_dead"></span> dead) Efficiency: <span id="efficiency"></span></p>
<p>Payout if a block were found NOW: <span id="payout_amount"></span> <span class="symbol"></span> to <span id="payout_addr"></span>. Expected after mining for 24 hours: <span id="expected_payout_amount"></span> <span class="symbol"></span> per block.</p>
<p>Payout if a block were found NOW: <span id="payout_amount"></span> <span class="symbol"></span> to <a id="payout_addr"></a>. Expected after mining for 24 hours: <span id="expected_payout_amount"></span> <span class="symbol"></span> per block.</p>
<p>Current block value: <span id="block_value"></span> <span class="symbol"></span> Expected time to block: <span id="time_to_block"></span></p>
<div id="warnings"></div>

Expand Down
23 changes: 15 additions & 8 deletions web-static/share.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
parent.append('a').attr('href', '#' + share.parent).text(share.parent.substr(-8));
var children = b.append('p');
children.append('span').text('Children: ');
children.data(share.children).append('a').attr('href', function(c){return '#' + c}).text(function(c){return c.substr(-8)});
children.selectAll().data(share.children).enter().append('span').text(' ').append('a')
.attr('href', function(c){return '#' + c})
.text(function(c){return c.substr(-8)});
b.append('p').text('Type: ' + share.type_name);
b.append('h2').text('Local data');
b.append('p').text('Verified: ' + share.local.verified);
Expand All @@ -51,7 +53,7 @@
b.append('p').text('Timestamp: ' + new Date(1000*share.share_data.timestamp) + ' (' + share.share_data.timestamp + ')');
b.append('p').text('Difficulty: ' + target_to_difficulty(share.share_data.target));
b.append('p').text('Minimum difficulty: ' + target_to_difficulty(share.share_data.max_target));
b.append('p').text('Payout address: ' + share.share_data.payout_address);
b.append('p').text('Payout address: ').append('a').text(share.share_data.payout_address).attr('href', currency_info.address_explorer_url_prefix+share.share_data.payout_address);
b.append('p').text('Donation amount: ' + d3.format('.3p')(share.share_data.donation));
b.append('p').text('Last stale: ' + share.share_data.stale_info);
b.append('p').text('Nonce: ' + share.share_data.nonce);
Expand All @@ -62,20 +64,25 @@
var block = b.append('p')
block.append('span').text('Hash: ')
block.append('a').attr('href', currency_info.block_explorer_url_prefix + share.block.hash).text(share.block.hash);
b.append('p').text('Transaction count: ' + share.block.txn_count);
b.append('h2').text('Header');
b.append('h3').text('Header');
b.append('p').text('Version: ' + share.block.header.version);
var prevblock = b.append('p')
prevblock.append('span').text('Previous block: ');
prevblock.append('a').attr('href', currency_info.block_explorer_url_prefix + share.block.header.previous_block).text(share.block.header.previous_block);
b.append('p').text('Merkle root: ' + share.block.header.merkle_root);
b.append('p').text('Timestamp: ' + share.block.header.timestamp);
b.append('p').text('Timestamp: ' + new Date(1000*share.block.header.timestamp) + ' (' + share.block.header.timestamp + ')');
b.append('p').text('Difficulty: ' + target_to_difficulty(share.block.header.target));
b.append('p').text('Nonce: ' + share.block.header.nonce);
b.append('h2').text('Generation transaction');
b.append('p').text('Hash: ' + share.block.gentx.hash);
b.append('p').text('Coinbase: ' + share.block.gentx.coinbase + ' ' + hex2a(share.block.gentx.coinbase));
b.append('h3').text('Generation transaction');
b.append('p').text('Hash: ').append('a').text(share.block.gentx.hash).attr('href', currency_info.tx_explorer_url_prefix+share.block.gentx.hash);
b.append('p').text('Coinbase (hex): ' + share.block.gentx.coinbase);
b.append('p').text('Coinbase (text): ' + hex2a(share.block.gentx.coinbase));
b.append('p').text('Value: ' + share.block.gentx.value + ' ' + currency_info.symbol);
b.append('p').text('Last txout nonce (used by Stratum miners): ' + share.block.gentx.last_txout_nonce);
b.append('h3').text('Other transactions');
b.append('p').selectAll().data(share.block.other_transaction_hashes).enter().append('span').text(' ').append('a')
.attr('href', function(tx_hash){return currency_info.tx_explorer_url_prefix + tx_hash})
.text(function(tx_hash, i){return i+1});
return true;
});
}
Expand Down

0 comments on commit 2872302

Please sign in to comment.