Add json dump to SN page

This commit is contained in:
Johnathan Ross 2021-06-09 12:09:15 +10:00
parent 9155a22b9c
commit 65e3c1ae7d
2 changed files with 29 additions and 4 deletions

View File

@ -415,9 +415,11 @@ def block_with_txs_req(lmq, oxend, hash_or_height, **kwargs):
return FutureJSON(lmq, oxend, 'rpc.get_block', cache_key='single', args=args, **kwargs)
@app.route('/service_node/<hex64:pubkey>') # For backwards compatibility with old explorer URLs
@app.route('/service_node/<hex64:pubkey>') # For backwards compatibility
@app.route('/service_node/<hex64:pubkey>/<int:more_details>') # with old explorer URLs
@app.route('/sn/<hex64:pubkey>')
def show_sn(pubkey):
@app.route('/sn/<hex64:pubkey>/<int:more_details>')
def show_sn(pubkey, more_details=False):
lmq, oxend = lmq_connection()
info = FutureJSON(lmq, oxend, 'rpc.get_info', 1)
hfinfo = FutureJSON(lmq, oxend, 'rpc.hard_fork_info', 10)
@ -442,11 +444,21 @@ def show_sn(pubkey):
# Available open contribution spots:
sn['num_open_spots'] = 0 if sn['total_reserved'] >= sn['staking_requirement'] else max(0, 4 - sn['num_contributions'] - sn['num_reserved_spots'])
if more_details:
formatter = HtmlFormatter(cssclass="syntax-highlight", style="paraiso-dark")
more_details = {
'details_css': formatter.get_style_defs('.syntax-highlight'),
'details_html': highlight(json.dumps(sn, indent="\t", sort_keys=True), JsonLexer(), formatter),
}
else:
more_details = {}
return flask.render_template('sn.html',
info=info.get(),
hf=hfinfo.get(),
sn=sn,
quorums=get_quorums(quos)
quorums=get_quorums(quos),
**more_details,
)

View File

@ -231,5 +231,18 @@
{%endfor%}
</table>
{%endif%}
{%if details_html%}
<style type="text/css">
{{details_css | safe}}
</style>
<div class="TitleDivider" id="more_details"></div>
{{details_html | safe}}
{%else%}
<h5>
<a href="/sn/{{sn.service_node_pubkey}}/1#more_details">Show raw details</a>
</h5>
{%endif%}
</div>
{%endblock%}
{% endblock %}