File tree Expand file tree Collapse file tree 2 files changed +27
-23
lines changed Expand file tree Collapse file tree 2 files changed +27
-23
lines changed Original file line number Diff line number Diff line change 9
9
import signal
10
10
import sys
11
11
import tempfile
12
+ import threading
13
+ from time import sleep
12
14
from typing import Dict
13
15
14
16
from kubernetes import client , config
@@ -100,6 +102,30 @@ def b64_to_hex(b64, reverse=False):
100
102
else :
101
103
return base64 .b64decode (b64 ).hex ()
102
104
105
+ def wait_for_tanks_connected (self ):
106
+ def tank_connected (self , tank ):
107
+ while True :
108
+ peers = tank .getpeerinfo ()
109
+ count = sum (
110
+ 1
111
+ for peer in peers
112
+ if peer .get ("connection_type" ) == "manual" or peer .get ("addnode" ) is True
113
+ )
114
+ self .log .info (f"Tank { tank .tank } connected to { count } /{ tank .init_peers } peers" )
115
+ if count >= tank .init_peers :
116
+ break
117
+ else :
118
+ sleep (1 )
119
+
120
+ conn_threads = [
121
+ threading .Thread (target = tank_connected , args = (self , tank )) for tank in self .nodes
122
+ ]
123
+ for thread in conn_threads :
124
+ thread .start ()
125
+
126
+ all (thread .join () is None for thread in conn_threads )
127
+ self .log .info ("Network connected" )
128
+
103
129
def handle_sigterm (self , signum , frame ):
104
130
print ("SIGTERM received, stopping..." )
105
131
self .shutdown ()
Original file line number Diff line number Diff line change @@ -20,29 +20,7 @@ def run_test(self):
20
20
# L1 P2P
21
21
##
22
22
self .log .info ("Waiting for L1 p2p network connections..." )
23
-
24
- def tank_connected (self , tank ):
25
- while True :
26
- peers = tank .getpeerinfo ()
27
- count = sum (
28
- 1
29
- for peer in peers
30
- if peer .get ("connection_type" ) == "manual" or peer .get ("addnode" ) is True
31
- )
32
- self .log .info (f"Tank { tank .tank } connected to { count } /{ tank .init_peers } peers" )
33
- if count >= tank .init_peers :
34
- break
35
- else :
36
- sleep (1 )
37
-
38
- conn_threads = [
39
- threading .Thread (target = tank_connected , args = (self , tank )) for tank in self .nodes
40
- ]
41
- for thread in conn_threads :
42
- thread .start ()
43
-
44
- all (thread .join () is None for thread in conn_threads )
45
- self .log .info ("Network connected" )
23
+ self .wait_for_tanks_connected ()
46
24
47
25
##
48
26
# MINER
You can’t perform that action at this time.
0 commit comments