Pass config and state to network.start()

This commit is contained in:
Dmitri Bogomolov 2021-03-03 11:51:05 +02:00
parent 54790ac2d9
commit 37344930f6
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 15 additions and 15 deletions

View File

@ -236,17 +236,8 @@ class Main(object):
# start network components if networking is enabled
if state.enableNetwork:
start_proxyconfig()
network.start()
network.start(config, state)
# Optional components
for i in range(config.getint('threads', 'receive')):
receiveQueueThread = network.ReceiveQueueThread(i)
receiveQueueThread.daemon = True
receiveQueueThread.start()
if config.safeGetBoolean('bitmessagesettings', 'udp'):
state.announceThread = network.AnnounceThread()
state.announceThread.daemon = True
state.announceThread.start()
if config.safeGetBoolean('bitmessagesettings', 'upnp'):
import upnp
upnpThread = upnp.uPnPThread()

View File

@ -4,19 +4,17 @@ Network subsystem package
from announcethread import AnnounceThread
from connectionpool import BMConnectionPool
from receivequeuethread import ReceiveQueueThread
from threads import StoppableThread
__all__ = [
"AnnounceThread", "BMConnectionPool",
"ReceiveQueueThread", "StoppableThread"
"AnnounceThread", "BMConnectionPool", "StoppableThread"
# "AddrThread", "AnnounceThread", "BMNetworkThread", "Dandelion",
# "DownloadThread", "InvThread", "UploadThread",
# "DownloadThread", "InvThread", "ReceiveQueueThread", "UploadThread",
]
def start():
def start(config, state):
"""Start network threads"""
from addrthread import AddrThread
from dandelion import Dandelion
@ -24,6 +22,7 @@ def start():
from invthread import InvThread
from networkthread import BMNetworkThread
from knownnodes import readKnownNodes
from receivequeuethread import ReceiveQueueThread
from uploadthread import UploadThread
readKnownNodes()
@ -45,3 +44,13 @@ def start():
uploadThread = UploadThread()
uploadThread.daemon = True
uploadThread.start()
# Optional components
for i in range(config.getint('threads', 'receive')):
receiveQueueThread = ReceiveQueueThread(i)
receiveQueueThread.daemon = True
receiveQueueThread.start()
if config.safeGetBoolean('bitmessagesettings', 'udp'):
state.announceThread = AnnounceThread()
state.announceThread.daemon = True
state.announceThread.start()