Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove electrum limit, sort by url #1153

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions utils/generate_app_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ def get_electrums(self):
e["url"] = k
del e["ws_url"]
valid_electrums.append(e)

if len(valid_electrums) > 0:
valid_electrums = sort_dicts_list(valid_electrums, "url")
self.data[self.ticker].update({"electrum": valid_electrums})

def get_bchd_urls(self):
Expand Down Expand Up @@ -484,7 +485,9 @@ def get_swap_contracts(self):
key = "rpc_urls"
else:
key = "nodes"
self.data[self.ticker].update({key: contract_data["rpc_nodes"]})

values = sort_dicts_list(contract_data["rpc_nodes"], "url")
self.data[self.ticker].update({key: values})

def get_explorers(self):
explorers = None
Expand Down Expand Up @@ -595,7 +598,6 @@ def filter_ssl(coins_config):
# For web, we only want SSL.
if i["protocol"] == "SSL":
electrums.append(i)
coins_config_ssl[coin]["electrum"] = electrums[:3]
if len(coins_config_ssl[coin]["electrum"]) == 0:
del coins_config_ssl[coin]

Expand Down Expand Up @@ -635,7 +637,7 @@ def filter_tcp(coins_config, coins_config_ssl):
if "nodes" in coins_config[coin]:
coins_config_tcp[coin]["nodes"] = [
i for i in coins_config[coin]["nodes"] if "gui_auth" not in i
][:3]
]
if "electrum" in coins_config[coin]:
electrums = []
# Prefer SSL
Expand All @@ -654,7 +656,7 @@ def filter_tcp(coins_config, coins_config_ssl):
else:
electrums.append(i)

coins_config_tcp[coin]["electrum"] = electrums[:3]
coins_config_tcp[coin]["electrum"] = electrums
if len(coins_config_tcp[coin]["electrum"]) == 0:
del coins_config_tcp[coin]

Expand All @@ -666,7 +668,6 @@ def filter_tcp(coins_config, coins_config_ssl):
def filter_wss(coins_config):
coins_config_wss = {}
for coin in coins_config:
coins_config_wss.update({coin: coins_config[coin]})
if "electrum" in coins_config[coin]:
electrums = []
for i in coins_config[coin]["electrum"]:
Expand All @@ -675,9 +676,9 @@ def filter_wss(coins_config):
electrums.append(i)
else:
print(i)
coins_config_wss[coin]["electrum"] = electrums[:3]
if len(coins_config_wss[coin]["electrum"]) == 0:
del coins_config_wss[coin]
if len(electrums) > 0:
coins_config_wss.update({coin: coins_config[coin]})
coins_config_wss[coin]["electrum"] = electrums

with open(f"{script_path}/coins_config_wss.json", "w+") as f:
json.dump(coins_config_wss, f, indent=4)
Expand Down Expand Up @@ -722,6 +723,14 @@ def generate_binance_api_ids(coins_config):
# Valid interval values are listed at https://binance-docs.github.io/apidocs/spot/en/#public-api-definitions


def sort_dict(d):
return {k: d[k] for k in sorted(d)}

def sort_dicts_list(data, sort_key):
return sorted(data, key=lambda x: x[sort_key])



if __name__ == "__main__":
ensure_chainids()
coins_config, nodata = parse_coins_repo()
Expand Down