diff --git a/src/api.py b/src/api.py index a44455695..7e628d90d 100644 --- a/src/api.py +++ b/src/api.py @@ -73,13 +73,13 @@ import helper_inbox import helper_sent -import protocol import proofofwork import queues import shared import shutdown import state +import network.protocol as protocol from addresses import ( addBMIfNotPresent, decodeAddress, diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index 469ccbfab..4555e9415 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -19,10 +19,10 @@ import helper_sent import highlevelcrypto import l10n -import protocol import queues import shared import state +import network.protocol as protocol from addresses import ( decodeAddress, decodeVarint, encodeAddress, encodeVarint, varintDecodeError diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index f2821f657..f2c949e8b 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -20,11 +20,11 @@ import highlevelcrypto import l10n import proofofwork -import protocol import queues import shared import state import tr +import network.protocol as protocol from addresses import decodeAddress, decodeVarint, encodeVarint from bmconfigparser import config from helper_sql import sqlExecute, sqlQuery diff --git a/src/network/bmobject.py b/src/network/bmobject.py index 83311b9b5..8b0f02be6 100644 --- a/src/network/bmobject.py +++ b/src/network/bmobject.py @@ -4,8 +4,8 @@ import logging import time -import protocol import state +import protocol import connectionpool from network import dandelion_ins from highlevelcrypto import calculateInventoryHash diff --git a/src/network/bmproto.py b/src/network/bmproto.py index 797dab5e8..068181b55 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -13,9 +13,9 @@ # magic imports! import addresses import knownnodes -import protocol import state import connectionpool +import protocol from bmconfigparser import config from queues import invQueue, objectProcessorQueue, portCheckerQueue from randomtrackingdict import RandomTrackingDict diff --git a/src/network/connectionchooser.py b/src/network/connectionchooser.py index d7062d247..1696c7ae5 100644 --- a/src/network/connectionchooser.py +++ b/src/network/connectionchooser.py @@ -6,8 +6,8 @@ import random import knownnodes -import protocol import state +import protocol from bmconfigparser import config from queues import queue, portCheckerQueue diff --git a/src/protocol.py b/src/network/protocol.py similarity index 96% rename from src/protocol.py rename to src/network/protocol.py index 96c980bbe..601c98cbc 100644 --- a/src/protocol.py +++ b/src/network/protocol.py @@ -13,16 +13,26 @@ from binascii import hexlify from struct import Struct, pack, unpack -import defaults -import highlevelcrypto -import state -from addresses import ( - encodeVarint, decodeVarint, decodeAddress, varintDecodeError) -from bmconfigparser import config -from debug import logger -from helper_sql import sqlExecute -from network.node import Peer -from version import softwareVersion +try: + import defaults + import highlevelcrypto + import state + from addresses import ( + encodeVarint, decodeVarint, decodeAddress, varintDecodeError) + from bmconfigparser import config + from debug import logger + from helper_sql import sqlExecute + from version import softwareVersion +except ImportError: + from pybitmessage import defaults, highlevelcrypto, state + from pybitmessage.addresses import ( + encodeVarint, decodeVarint, decodeAddress, varintDecodeError) + from pybitmessage.bmconfigparser import config + from pybitmessage.debug import logger + from pybitmessage.helper_sql import sqlExecute + from pybitmessage.version import softwareVersion + +from .node import Peer # Network constants magic = 0xE9BEB4D9 diff --git a/src/tests/core.py b/src/tests/core.py index fd9b0d08b..d610c0491 100644 --- a/src/tests/core.py +++ b/src/tests/core.py @@ -16,10 +16,10 @@ import time import unittest -import protocol import state import helper_sent import helper_addressbook +import network.protocol as protocol from bmconfigparser import config from helper_msgcoding import MsgEncode, MsgDecode diff --git a/src/tests/test_api_thread.py b/src/tests/test_api_thread.py index 6e453b192..e28f20b8a 100644 --- a/src/tests/test_api_thread.py +++ b/src/tests/test_api_thread.py @@ -7,7 +7,7 @@ from six.moves import queue, xmlrpc_client -from pybitmessage import protocol +from pybitmessage.network import protocol from pybitmessage.highlevelcrypto import calculateInventoryHash from .partial import TestPartialRun diff --git a/src/tests/test_packets.py b/src/tests/test_packets.py index 9dfb1d23a..e6471017e 100644 --- a/src/tests/test_packets.py +++ b/src/tests/test_packets.py @@ -3,7 +3,8 @@ from binascii import unhexlify from struct import pack -from pybitmessage import addresses, protocol +from pybitmessage import addresses +from pybitmessage.network import protocol from .samples import ( sample_addr_data, sample_object_data, sample_object_expires) diff --git a/src/tests/test_protocol.py b/src/tests/test_protocol.py index e3137b25a..e923b8994 100644 --- a/src/tests/test_protocol.py +++ b/src/tests/test_protocol.py @@ -5,7 +5,8 @@ import sys import unittest -from pybitmessage import protocol, state +from pybitmessage import state +from pybitmessage.network import protocol from pybitmessage.helper_startup import fixSocket