|
2 | 2 | Network subsystem package |
3 | 3 | """ |
4 | 4 |
|
5 | | -from announcethread import AnnounceThread |
6 | | -from connectionpool import BMConnectionPool |
7 | | -from receivequeuethread import ReceiveQueueThread |
8 | | -from threads import StoppableThread |
| 5 | +from .connectionpool import BMConnectionPool |
| 6 | +from .threads import StoppableThread |
9 | 7 |
|
10 | 8 |
|
11 | | -__all__ = [ |
12 | | - "AnnounceThread", "BMConnectionPool", |
13 | | - "ReceiveQueueThread", "StoppableThread" |
14 | | - # "AddrThread", "AnnounceThread", "BMNetworkThread", "Dandelion", |
15 | | - # "DownloadThread", "InvThread", "UploadThread", |
16 | | -] |
| 9 | +__all__ = ["BMConnectionPool", "StoppableThread"] |
17 | 10 |
|
18 | 11 |
|
19 | | -def start(): |
| 12 | +def start(config, state): |
20 | 13 | """Start network threads""" |
21 | | - from addrthread import AddrThread |
22 | | - from dandelion import Dandelion |
23 | | - from downloadthread import DownloadThread |
24 | | - from invthread import InvThread |
25 | | - from networkthread import BMNetworkThread |
26 | | - from knownnodes import readKnownNodes |
27 | | - from uploadthread import UploadThread |
| 14 | + from .addrthread import AddrThread |
| 15 | + from .announcethread import AnnounceThread |
| 16 | + from .dandelion import Dandelion |
| 17 | + from .downloadthread import DownloadThread |
| 18 | + from .invthread import InvThread |
| 19 | + from .networkthread import BMNetworkThread |
| 20 | + from .knownnodes import readKnownNodes |
| 21 | + from .receivequeuethread import ReceiveQueueThread |
| 22 | + from .uploadthread import UploadThread |
28 | 23 |
|
29 | 24 | readKnownNodes() |
30 | 25 | # init, needs to be early because other thread may access it early |
31 | 26 | Dandelion() |
32 | 27 | BMConnectionPool().connectToStream(1) |
33 | | - asyncoreThread = BMNetworkThread() |
34 | | - asyncoreThread.daemon = True |
35 | | - asyncoreThread.start() |
36 | | - invThread = InvThread() |
37 | | - invThread.daemon = True |
38 | | - invThread.start() |
39 | | - addrThread = AddrThread() |
40 | | - addrThread.daemon = True |
41 | | - addrThread.start() |
42 | | - downloadThread = DownloadThread() |
43 | | - downloadThread.daemon = True |
44 | | - downloadThread.start() |
45 | | - uploadThread = UploadThread() |
46 | | - uploadThread.daemon = True |
47 | | - uploadThread.start() |
| 28 | + for thread in ( |
| 29 | + BMNetworkThread(), InvThread(), AddrThread(), |
| 30 | + DownloadThread(), UploadThread() |
| 31 | + ): |
| 32 | + thread.daemon = True |
| 33 | + thread.start() |
| 34 | + |
| 35 | + # Optional components |
| 36 | + for i in range(config.getint('threads', 'receive')): |
| 37 | + thread = ReceiveQueueThread(i) |
| 38 | + thread.daemon = True |
| 39 | + thread.start() |
| 40 | + if config.safeGetBoolean('bitmessagesettings', 'udp'): |
| 41 | + state.announceThread = AnnounceThread() |
| 42 | + state.announceThread.daemon = True |
| 43 | + state.announceThread.start() |
0 commit comments