From 37344930f635277b9f38260cceac6905142b6db7 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 3 Mar 2021 11:51:05 +0200 Subject: [PATCH] Pass config and state to network.start() --- src/bitmessagemain.py | 11 +---------- src/network/__init__.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 99cb34db..438c04f3 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -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() diff --git a/src/network/__init__.py b/src/network/__init__.py index ab1e3170..9236c757 100644 --- a/src/network/__init__.py +++ b/src/network/__init__.py @@ -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()