in benchmark/benchmark/config.py [0:0]
def __init__(self, addresses, base_port):
''' The `addresses` field looks as follows:
{
"name": ["host", "host", ...],
...
}
'''
assert isinstance(addresses, OrderedDict)
assert all(isinstance(x, str) for x in addresses.keys())
assert all(
isinstance(x, list) and len(x) > 1 for x in addresses.values()
)
assert all(
isinstance(x, str) for y in addresses.values() for x in y
)
assert len({len(x) for x in addresses.values()}) == 1
assert isinstance(base_port, int) and base_port > 1024
port = base_port
self.json = {'authorities': OrderedDict()}
for name, hosts in addresses.items():
host = hosts.pop(0)
primary_addr = {
'primary_to_primary': f'{host}:{port}',
'worker_to_primary': f'{host}:{port + 1}'
}
port += 2
workers_addr = OrderedDict()
for j, host in enumerate(hosts):
workers_addr[j] = {
'primary_to_worker': f'{host}:{port}',
'transactions': f'{host}:{port + 1}',
'worker_to_worker': f'{host}:{port + 2}',
}
port += 3
self.json['authorities'][name] = {
'stake': 1,
'primary': primary_addr,
'workers': workers_addr
}