This commit is contained in:
Ian Macdonald 2022-07-14 13:22:33 -03:00 committed by GitHub
commit 027501c55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
279 changed files with 25 additions and 2 deletions

View File

@ -6,3 +6,4 @@ from observer import config
# Example config override:
#config.blocks_per_page = 10
config.geoip_dir = '/var/lib/GeoIP'

View File

@ -26,6 +26,7 @@ import sha3
import config
import local_config
from lmq import FutureJSON, omq_connection
import geoip2.database
# Make a dict of config.* to pass to templating
conf = {x: getattr(config, x) for x in dir(config) if not x.startswith('__')}
@ -47,7 +48,6 @@ class Hex64Converter(BaseConverter):
app.url_map.converters['hex64'] = Hex64Converter
@app.template_filter('format_datetime')
def format_datetime(value, format='long'):
return babel.dates.format_datetime(value, format, tzinfo=babel.dates.get_timezone('UTC'))
@ -186,10 +186,11 @@ def get_sns_future(omq, oxend):
'last_reward_transaction_index', 'active', 'funded', 'earned_downtime_blocks',
'service_node_version', 'contributors', 'total_contributed', 'total_reserved',
'staking_requirement', 'portions_for_operator', 'operator_address', 'pubkey_ed25519',
'last_uptime_proof', 'state_height', 'swarm_id') } })
'last_uptime_proof', 'state_height', 'swarm_id', 'public_ip') } })
def get_sns(sns_future, info_future):
info = info_future.get()
geoip = geoip2.database.Reader(config.geoip_dir + '/GeoLite2-City.mmdb')
awaiting_sns, active_sns, inactive_sns = [], [], []
sn_states = sns_future.get()
sn_states = sn_states['service_node_states'] if 'service_node_states' in sn_states else []
@ -197,6 +198,8 @@ def get_sns(sns_future, info_future):
sn['contribution_open'] = sn['staking_requirement'] - sn['total_reserved']
sn['contribution_required'] = sn['staking_requirement'] - sn['total_contributed']
sn['num_contributions'] = sum(len(x['locked_contributions']) for x in sn['contributors'] if 'locked_contributions' in x)
sn['country'] = geoip.city(sn['public_ip']).country.names['en']
sn['iso_code'] = geoip.city(sn['public_ip']).country.iso_code
if sn['active']:
active_sns.append(sn)
@ -571,6 +574,8 @@ def show_sn(pubkey, more_details=False):
hfinfo = FutureJSON(omq, oxend, 'rpc.hard_fork_info', 10)
sn = sn_req(omq, oxend, pubkey).get()
quos = get_quorums_future(omq, oxend, info.get()['height'])
geoip_c = geoip2.database.Reader(config.geoip_dir + '/GeoLite2-City.mmdb')
geoip_a = geoip2.database.Reader(config.geoip_dir + '/GeoLite2-ASN.mmdb')
if 'service_node_states' not in sn or not sn['service_node_states']:
@ -589,6 +594,12 @@ def show_sn(pubkey, more_details=False):
sn['num_reserved_spots'] = sum(x["amount"] < x["reserved"] for x in sn["contributors"])
# 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'])
sn['country'] = geoip_c.city(sn['public_ip']).country.names['en']
sn['iso_code'] = geoip_c.city(sn['public_ip']).country.iso_code
city = geoip_c.city(sn['public_ip']).city
if city.names:
sn['city'] = city.names['en']
sn['asn'] = geoip_a.asn(sn['public_ip']).autonomous_system_organization
if more_details:
formatter = HtmlFormatter(cssclass="syntax-highlight", style="paraiso-dark")

BIN
static/flags/AC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
static/flags/AD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

BIN
static/flags/AE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

BIN
static/flags/AF.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

BIN
static/flags/AG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

BIN
static/flags/AI-alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
static/flags/AI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

BIN
static/flags/AL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

BIN
static/flags/AM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
static/flags/AO.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

BIN
static/flags/AQ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

BIN
static/flags/AR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

BIN
static/flags/AS.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/flags/AT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 B

BIN
static/flags/AU.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

BIN
static/flags/AW.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
static/flags/AX.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

BIN
static/flags/AZ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

BIN
static/flags/BA.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

BIN
static/flags/BB.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

BIN
static/flags/BD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
static/flags/BE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

BIN
static/flags/BF.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

BIN
static/flags/BG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
static/flags/BH.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

BIN
static/flags/BI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

BIN
static/flags/BJ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

BIN
static/flags/BL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/flags/BM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/flags/BN.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
static/flags/BO-alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
static/flags/BO.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

BIN
static/flags/BQ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

BIN
static/flags/BR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

BIN
static/flags/BS.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

BIN
static/flags/BT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/flags/BV.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

BIN
static/flags/BW.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

BIN
static/flags/BY-alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 B

BIN
static/flags/BY.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

BIN
static/flags/BZ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

BIN
static/flags/CA.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

BIN
static/flags/CC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

BIN
static/flags/CD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

BIN
static/flags/CF.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

BIN
static/flags/CG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

BIN
static/flags/CH.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

BIN
static/flags/CI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

BIN
static/flags/CK.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

BIN
static/flags/CL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

BIN
static/flags/CM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

BIN
static/flags/CN.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

BIN
static/flags/CO.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

BIN
static/flags/CP.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

BIN
static/flags/CR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

BIN
static/flags/CU.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

BIN
static/flags/CV.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

BIN
static/flags/CW.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
static/flags/CX.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
static/flags/CY.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

BIN
static/flags/CZ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

BIN
static/flags/DE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
static/flags/DG-alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

BIN
static/flags/DG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

BIN
static/flags/DJ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

BIN
static/flags/DK.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
static/flags/DM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

BIN
static/flags/DO.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

BIN
static/flags/DZ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

BIN
static/flags/EA-alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
static/flags/EA.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

BIN
static/flags/EC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

BIN
static/flags/EE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
static/flags/EG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

BIN
static/flags/EH.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

BIN
static/flags/ER.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/flags/ES.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

BIN
static/flags/ET.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

BIN
static/flags/EU.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

BIN
static/flags/FI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
static/flags/FJ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/flags/FK.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
static/flags/FM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
static/flags/FO.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

BIN
static/flags/FR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

BIN
static/flags/GA.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
static/flags/GB.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 790 B

BIN
static/flags/GD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

BIN
static/flags/GE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

BIN
static/flags/GF.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

BIN
static/flags/GG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

BIN
static/flags/GH.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

BIN
static/flags/GI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

BIN
static/flags/GL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

BIN
static/flags/GM.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

BIN
static/flags/GN.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

BIN
static/flags/GP-alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

BIN
static/flags/GP.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Some files were not shown because too many files have changed in this diff Show More