# Path: bts_tools/network_utils.py
# @copy_cached_value
# @cachetools.func.lfu_cache(8192)
# def get_geoip_info(ip_addr):
#     try:
#         cred = core.config.get('credentials', {})['geoip2']  # check that we have a geoip2 section in config.yaml
#         client = geoip2.webservice.Client(cred['user'], cred['password'])
#     except KeyError as e:
#         raise ValueError('No geoip2 user and password defined in config.yaml') from e
# 
# 
#     log.debug('getting geoip2 info for for {}'.format(ip_addr))
#     response = client.city(ip_addr)
# 
#     pt = {'country': response.country.name,
#           'country_iso': response.country.iso_code,
#           'lat': response.location.latitude,
#           'lon': response.location.longitude
#           }
# 
#     log.debug('  {} -- {} ({}, {})'.format(ip_addr, pt['country'], pt['lat'], pt['lon']))
#     return pt
# 
# @cachetools.func.ttl_cache(maxsize=8192, ttl=3600)
# def resolve_dns(host):
#     if ':' in host:
#         ip, port = host.split(':')
#         return '%s:%s' % (resolve_dns(ip), port)
#     try:
#         return socket.gethostbyname(host)
#     except socket.gaierror:
#         log.warning('Cannot resolve host "{}"'.format(host))
#         return host


from bts_tools.network_utils import get_geoip_info, resolve_dns
from collections import defaultdict, deque
import socket
import time
import threading
import logging
        ('seed.therealwolf.me:2001',         'fi', 'therealwolf',    'https://steemit.com/witness-update/@therealwolf/witness-essentials-hf20-ready'),
        ('seed.yabapmatt.com:2001',          'de', 'yabapmatt',      'https://steemit.com/witness-category/@yabapmatt/yabapmatt-s-monster-1-year-steemiversary-witness-update')
    ],
    'ppy': [
        ('seed.ppy.blckchnd.com:6112',     '', 'blckchnd', ''),
        ('5.9.18.213:18828',               '', 'pfunk', ''),
        ('31.171.244.121:7777',            '', 'taconator', ''),
        ('seed.peerplaysdb.com:9777',      '', 'jesta', ''),
        ('ppy.esteem.ws:7777',             '', 'good-karma', ''),
        ('peerplays.roelandp.nl:9777',     '', 'roelandp', ''),
        ('ppy-seed.xeldal.com:19777',      '', 'xeldal', ''),
        ('seed.peerplaysnodes.com:9777',   '', 'wackou', ''),
        ('peerplays-seed.privex.io:7777',  '', 'someguy123/privex', ''),
        ('peerplays.agoric.systems:9777',  '', 'agoric.systems', ''),
        ('212.71.253.163:9777',            '', 'xtar', ''),
        ('51.15.35.96:9777',               '', 'lafona', ''),
        ('anyx.ca:9777',                   '', 'anyx', ''),
        ('ppyseed.nuevax.com:19777',       '', 'nuevax', ''),
        ('82.223.108.91:7777',             '', 'hiltos', ''),
        ('peerplays.butler.net:9777',      '', 'billbutler', ''),
        ('peerplays.bitcoiner.me:9777',    '', 'bitcoiner', ''),
        ('peerplays.bhuz.info:9777',       '', 'bhuz', ''),
        ('node.peerblock.trade:9777',      '', 'bitcoin-sig', ''),
        ('peerplays.crypto.fans:9777',     '', 'sc-steemit / crypto.fans', ''),
        ('23.227.163.201:9777',            '', 'royal-flush', '')
    ]
}

def check_valid_seed_nodes():
    for chain, seeds in SEED_NODES.items():

# Path: bts_tools/network_utils.py
# @copy_cached_value
# @cachetools.func.lfu_cache(8192)
# def get_geoip_info(ip_addr):
#     try:
#         cred = core.config.get('credentials', {})['geoip2']  # check that we have a geoip2 section in config.yaml
#         client = geoip2.webservice.Client(cred['user'], cred['password'])
#     except KeyError as e:
#         raise ValueError('No geoip2 user and password defined in config.yaml') from e
# 
# 
#     log.debug('getting geoip2 info for for {}'.format(ip_addr))
#     response = client.city(ip_addr)
# 
#     pt = {'country': response.country.name,
#           'country_iso': response.country.iso_code,
#           'lat': response.location.latitude,
#           'lon': response.location.longitude
#           }
# 
#     log.debug('  {} -- {} ({}, {})'.format(ip_addr, pt['country'], pt['lat'], pt['lon']))
#     return pt
# 
# @cachetools.func.ttl_cache(maxsize=8192, ttl=3600)
# def resolve_dns(host):
#     if ':' in host:
#         ip, port = host.split(':')
#         return '%s:%s' % (resolve_dns(ip), port)
#     try:
#         return socket.gethostbyname(host)
#     except socket.gaierror:
#         log.warning('Cannot resolve host "{}"'.format(host))
#         return host


# Path: bts_tools/seednodes.py
from bts_tools.network_utils import get_geoip_info, resolve_dns
from collections import defaultdict, deque
import socket
import time
import threading
import logging

        ('seed.therealwolf.me:2001',         'fi', 'therealwolf',    'https://steemit.com/witness-update/@therealwolf/witness-essentials-hf20-ready'),
        ('seed.yabapmatt.com:2001',          'de', 'yabapmatt',      'https://steemit.com/witness-category/@yabapmatt/yabapmatt-s-monster-1-year-steemiversary-witness-update')
    ],
    'ppy': [
        ('seed.ppy.blckchnd.com:6112',     '', 'blckchnd', ''),
        ('5.9.18.213:18828',               '', 'pfunk', ''),
        ('31.171.244.121:7777',            '', 'taconator', ''),
        ('seed.peerplaysdb.com:9777',      '', 'jesta', ''),
        ('ppy.esteem.ws:7777',             '', 'good-karma', ''),
        ('peerplays.roelandp.nl:9777',     '', 'roelandp', ''),
        ('ppy-seed.xeldal.com:19777',      '', 'xeldal', ''),
        ('seed.peerplaysnodes.com:9777',   '', 'wackou', ''),
        ('peerplays-seed.privex.io:7777',  '', 'someguy123/privex', ''),
        ('peerplays.agoric.systems:9777',  '', 'agoric.systems', ''),
        ('212.71.253.163:9777',            '', 'xtar', ''),
        ('51.15.35.96:9777',               '', 'lafona', ''),
        ('anyx.ca:9777',                   '', 'anyx', ''),
        ('ppyseed.nuevax.com:19777',       '', 'nuevax', ''),
        ('82.223.108.91:7777',             '', 'hiltos', ''),
        ('peerplays.butler.net:9777',      '', 'billbutler', ''),
        ('peerplays.bitcoiner.me:9777',    '', 'bitcoiner', ''),
        ('peerplays.bhuz.info:9777',       '', 'bhuz', ''),
        ('node.peerblock.trade:9777',      '', 'bitcoin-sig', ''),
        ('peerplays.crypto.fans:9777',     '', 'sc-steemit / crypto.fans', ''),
        ('23.227.163.201:9777',            '', 'royal-flush', '')
    ]
}

def check_valid_seed_nodes():
    for chain, seeds in SEED_NODES.items():

        ips = [(host, resolve_dns(host), provider) for host, _, provider, *_ in seeds]