initial testnet support (petrkr)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user