1
0

initial testnet support (petrkr)

This commit is contained in:
ThomasV
2017-01-07 16:58:23 +01:00
parent 9138cf3cb8
commit d042d6e970
8 changed files with 82 additions and 71 deletions

View File

@@ -64,6 +64,14 @@ DEFAULT_SERVERS = {
'btc.mustyoshi.com':{'t':'50001', 's':'50002'},
}
def set_testnet():
global DEFAULT_PORTS, DEFAULT_SERVERS
DEFAULT_PORTS = {'t':'51001', 's':'51002'}
DEFAULT_SERVERS = {
'14.3.140.101': DEFAULT_PORTS,
'testnet.not.fyi': DEFAULT_PORTS
}
NODES_RETRY_INTERVAL = 60
SERVER_RETRY_INTERVAL = 10
@@ -99,7 +107,7 @@ def parse_servers(result):
return servers
def filter_protocol(hostmap = DEFAULT_SERVERS, protocol = 's'):
def filter_protocol(hostmap, protocol = 's'):
'''Filters the hostmap for those implementing protocol.
The result is a list in serialized form.'''
eligible = []
@@ -109,7 +117,9 @@ def filter_protocol(hostmap = DEFAULT_SERVERS, protocol = 's'):
eligible.append(serialize_server(host, port, protocol))
return eligible
def pick_random_server(hostmap = DEFAULT_SERVERS, protocol = 's', exclude_set = set()):
def pick_random_server(hostmap = None, protocol = 's', exclude_set = set()):
if hostmap is None:
hostmap = DEFAULT_SERVERS
eligible = list(set(filter_protocol(hostmap, protocol)) - exclude_set)
return random.choice(eligible) if eligible else None