From b99670430f3c095155468c659020f9bc7da365b7 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Wed, 4 Jan 2023 01:29:05 +0200 Subject: [PATCH] Emphasize more magic imports in the network package --- src/network/addrthread.py | 6 +++--- src/network/announcethread.py | 3 ++- src/network/bmproto.py | 13 ++++++++----- src/network/tcp.py | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/network/addrthread.py b/src/network/addrthread.py index dfd0738f..fea0910e 100644 --- a/src/network/addrthread.py +++ b/src/network/addrthread.py @@ -3,13 +3,13 @@ Announce addresses as they are received from other hosts """ from six.moves import queue - +# magic imports! import state from helper_random import randomshuffle from protocol import assembleAddrMessage - +from queues import addrQueue # FIXME: init with queue from network.connectionpool import BMConnectionPool -from queues import addrQueue + from threads import StoppableThread diff --git a/src/network/announcethread.py b/src/network/announcethread.py index cc82051a..5fcf0dfa 100644 --- a/src/network/announcethread.py +++ b/src/network/announcethread.py @@ -3,11 +3,12 @@ Announce myself (node address) """ import time +# magic imports! import state from bmconfigparser import config from protocol import assembleAddrMessage - from network.connectionpool import BMConnectionPool + from node import Peer from threads import StoppableThread diff --git a/src/network/bmproto.py b/src/network/bmproto.py index 9e6d5044..c4f8462a 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -11,6 +11,7 @@ import struct import time from binascii import hexlify +# magic imports! import addresses import connectionpool import knownnodes @@ -18,22 +19,24 @@ import protocol import state from bmconfigparser import config from inventory import Inventory +from queues import invQueue, objectProcessorQueue, portCheckerQueue +from randomtrackingdict import RandomTrackingDict from network.advanceddispatcher import AdvancedDispatcher from network.bmobject import ( BMObject, BMObjectAlreadyHaveError, BMObjectExpiredError, BMObjectInsufficientPOWError, BMObjectInvalidError, BMObjectUnwantedStreamError ) -from network.constants import ( +from network.dandelion import Dandelion +from network.proxy import ProxyError + +from constants import ( ADDRESS_ALIVE, MAX_MESSAGE_SIZE, MAX_OBJECT_COUNT, MAX_OBJECT_PAYLOAD_SIZE, MAX_TIME_OFFSET ) -from network.dandelion import Dandelion -from network.proxy import ProxyError from node import Node, Peer from objectracker import ObjectTracker, missingObjects -from queues import invQueue, objectProcessorQueue, portCheckerQueue -from randomtrackingdict import RandomTrackingDict + logger = logging.getLogger('default') diff --git a/src/network/tcp.py b/src/network/tcp.py index c68adf46..ae473281 100644 --- a/src/network/tcp.py +++ b/src/network/tcp.py @@ -9,6 +9,7 @@ import random import socket import time +# magic imports! import addresses import helper_random import l10n @@ -23,9 +24,9 @@ from tr import _translate import asyncore_pollchoose as asyncore import connectionpool import knownnodes +from constants import MAX_OBJECT_COUNT from network.advanceddispatcher import AdvancedDispatcher from network.bmproto import BMProto -from network.constants import MAX_OBJECT_COUNT from network.dandelion import Dandelion from network.objectracker import ObjectTracker from network.socks4a import Socks4aConnection