Skip to content

Commit 7ed33e9

Browse files
committed
smol fix , adds degree
1 parent 6a92fa2 commit 7ed33e9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/utils/pubsub/utils.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@ def make_pubsub_msg(
2424
)
2525

2626

27-
# TODO: Implement sparse connect
2827
async def dense_connect(hosts: Sequence[IHost]) -> None:
2928
await connect_some(hosts, 10)
3029

3130

32-
# FIXME: `degree` is not used at all
3331
async def connect_some(hosts: Sequence[IHost], degree: int) -> None:
32+
"""
33+
Connect each host to up to 'degree' number of other hosts.
34+
Creates a sparse network topology where each node has limited connections.
35+
"""
3436
for i, host in enumerate(hosts):
35-
for host2 in hosts[i + 1 :]:
36-
await connect(host, host2)
37+
connections_made = 0
38+
for j in range(i + 1, len(hosts)):
39+
if connections_made >= degree:
40+
break
41+
await connect(host, hosts[j])
42+
connections_made += 1
3743

3844

3945
async def one_to_all_connect(hosts: Sequence[IHost], central_host_index: int) -> None:

0 commit comments

Comments
 (0)