Changed batching since starlark does not support yield

This commit is contained in:
Alberto Soutullo 2023-02-09 13:08:12 +01:00 committed by Alberto Soutullo Rendo
parent 2b23357f48
commit 8e7c1e1127
2 changed files with 4 additions and 8 deletions

View File

@ -8,7 +8,7 @@ WAKU_LIBP2P_PORT_ID = "libp2p"
WAKU_LIBP2P_PORT = 60000
WAKU_SETUP_WAIT_TIME = "5"
WAKU_INTERCONNECTION_BATCH = "4"
WAKU_INTERCONNECTION_BATCH = 4
NODE_CONFIG_FILE_LOCATION = "github.com/logos-co/wakurtosis/config/topology_generated/"

View File

@ -89,17 +89,13 @@ def get_waku_peers(plan, waku_service_name):
def interconnect_waku_nodes(plan, topology_information, services):
def batch(iterable, n=1):
l = len(iterable)
for ndx in range(0, l, n):
yield iterable[ndx:min(ndx + n, l)]
# Interconnect them
for waku_service_name in services.keys():
peers = topology_information[waku_service_name]["static_nodes"]
for peer_batch in batch(peers, system_variables.WAKU_INTERCONNECTION_BATCH):
peer_ids = [create_waku_id(services[peer]) for peer in peer_batch]
for i in range(0, len(peers), system_variables.WAKU_INTERCONNECTION_BATCH):
x = i
peer_ids = [create_waku_id(services[peer]) for peer in peers[x:x+system_variables.WAKU_INTERCONNECTION_BATCH]]
connect_wakunode_to_peers(plan, waku_service_name, system_variables.WAKU_RPC_PORT_ID, peer_ids)