Skip to content
Snippets Groups Projects
Unverified Commit b465c3c4 authored by Brian of London's avatar Brian of London
Browse files

More robust HIVE_CHAIN_ID detection

Taken from this commit:

108e2e25

By Holger
parent 703763ee
No related branches found
No related tags found
1 merge request!12Prioritize HIVE_CHAIN_ID property for the chain selection
......@@ -304,15 +304,35 @@ class GrapheneRPC(object):
prefix = None
symbols = []
chain_assets = []
if 'HIVE_CHAIN_ID' in props and 'STEEM_CHAIN_ID' in props:
prefix_count = {}
for key in props:
if key.split("_")[0] in prefix_count:
prefix_count[key.split("_")[0]] += 1
else:
prefix_count[key.split("_")[0]] = 1
if len(prefix_count) > 0:
sorted_prefix_count = sorted(prefix_count.items(), key=lambda x: x[1], reverse=True)
if sorted_prefix_count[0][1] > 1:
blockchain_name = sorted_prefix_count[0][0]
if blockchain_name is None and 'HIVE_CHAIN_ID' in props and 'STEEM_CHAIN_ID' in props:
del props['STEEM_CHAIN_ID']
for key in props:
if key[-8:] == "CHAIN_ID":
if key[-8:] == "CHAIN_ID" and blockchain_name is None:
chain_id = props[key]
blockchain_name = key.split("_")[0]
elif key[-13:] == "CHAIN_VERSION":
elif key[-8:] == "CHAIN_ID" and key.split("_")[0] == blockchain_name:
chain_id = props[key]
elif key[-13:] == "CHAIN_VERSION" and blockchain_name is None:
network_version = props[key]
elif key[-14:] == "ADDRESS_PREFIX":
elif key[-13:] == "CHAIN_VERSION" and key.split("_")[0] == blockchain_name:
network_version = props[key]
elif key[-14:] == "ADDRESS_PREFIX" and blockchain_name is None:
prefix = props[key]
elif key[-14:] == "ADDRESS_PREFIX" and key.split("_")[0] == blockchain_name:
prefix = props[key]
elif key[-6:] == "SYMBOL":
value = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment