Skip to content

Commit

Permalink
Connect all nodes in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Mar 20, 2024
1 parent 4c164de commit 0842170
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import random
import re
from concurrent.futures import ThreadPoolExecutor
from subprocess import CalledProcessError
import time

Expand Down Expand Up @@ -384,11 +385,21 @@ def connect_nodes(from_connection, node_num):
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))

def connect_nodes_clique(nodes):
# max_workers should be the maximum number of nodes that we have in the same functional test,
# 15 seems to be a good upper bound
parallel_exec = ThreadPoolExecutor(max_workers=15)
l = len(nodes)
for a in range(l):
for b in range(a, l):
def connect_nodes_clique_internal(a):
for b in range(0, l):
connect_nodes(nodes[a], b)
connect_nodes(nodes[b], a)
jobs = []
for a in range(l):
jobs.append(parallel_exec.submit(connect_nodes_clique_internal, a))

for job in jobs:
job.result()
jobs.clear()
parallel_exec.shutdown()

# Transaction/Block functions
#############################
Expand Down

0 comments on commit 0842170

Please sign in to comment.