From 8e7c1e1127f17153564a12498fe2d7cc144a0357 Mon Sep 17 00:00:00 2001 From: Alberto Soutullo Date: Thu, 9 Feb 2023 13:08:12 +0100 Subject: [PATCH] Changed batching since starlark does not support yield --- src/system_variables.star | 2 +- src/waku.star | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/system_variables.star b/src/system_variables.star index cfc17fc..7e3e4fe 100644 --- a/src/system_variables.star +++ b/src/system_variables.star @@ -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/" diff --git a/src/waku.star b/src/waku.star index 64f3264..f390cb1 100644 --- a/src/waku.star +++ b/src/waku.star @@ -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)