From 9f4d6dca897e5267b552692ce820fecfa498fb1d Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Fri, 30 Apr 2021 12:52:57 -0300 Subject: [PATCH] Add next-test time to SN details page --- observer.py | 5 +++++ templates/sn.html | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/observer.py b/observer.py index 7bd813b..e658ad3 100644 --- a/observer.py +++ b/observer.py @@ -33,6 +33,8 @@ else: app = flask.Flask(__name__) +app.jinja_options['extensions'].append('jinja2.ext.loopcontrols') + class Hex64Converter(BaseConverter): def __init__(self, url_map): super().__init__(url_map) @@ -420,6 +422,8 @@ def show_sn(pubkey): info = FutureJSON(lmq, oxend, 'rpc.get_info', 1) hfinfo = FutureJSON(lmq, oxend, 'rpc.hard_fork_info', 10) sn = sn_req(lmq, oxend, pubkey).get() + quos = get_quorums_future(lmq, oxend, info.get()['height']) + if 'service_node_states' not in sn or not sn['service_node_states']: return flask.render_template('not_found.html', @@ -442,6 +446,7 @@ def show_sn(pubkey): info=info.get(), hf=hfinfo.get(), sn=sn, + quorums=get_quorums(quos) ) diff --git a/templates/sn.html b/templates/sn.html index 53bc5b5..3fa7ff1 100644 --- a/templates/sn.html +++ b/templates/sn.html @@ -124,6 +124,28 @@ {%if sn.swarm_id == 18446744073709551615%}(none){%else%}0x{{'{:016x}'.format(sn.swarm_id)}}{%endif%} + + {%set next_test = namespace(height=none)%} + {%for q in quorums.obligation[-13:]%} + {%if next_test.height%}{%break%}{%endif%} + {%if q.height + 13 >= info.height%} + {%for w in q.quorum.workers%} + {%if w == sn.service_node_pubkey%} + {%set next_test.height = q.height + 13%} + {%break%} + {%endif%} + {%endfor%} + {%endif%} + {%endfor%} + + + {%if next_test.height%} + Block {{next_test.height}} + ({%if next_test.height == info.height%}Now!{%else%}~{{((next_test.height - info.height) * 120) | reltime(in_ago=false)}}{%endif%}) + {%else%} + Unknown + {%endif%} +