Skip to content

Commit

Permalink
Moved protocol to network module
Browse files Browse the repository at this point in the history
  • Loading branch information
anand-skss committed Jul 4, 2024
1 parent 65d2a37 commit 8c8f0f3
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/class_objectProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/class_singleWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/network/bmobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/network/bmproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/network/connectionchooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import random

import knownnodes
import protocol
import state
import protocol
from bmconfigparser import config
from queues import queue, portCheckerQueue

Expand Down
30 changes: 20 additions & 10 deletions src/protocol.py → src/network/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_api_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import sys
import unittest

from pybitmessage import protocol, state
from pybitmessage.helper_startup import fixSocket
from pybitmessage import state
from pybitmessage.network import protocol
from helper_startup import fixSocket


class TestSocketInet(unittest.TestCase):
Expand Down

0 comments on commit 8c8f0f3

Please sign in to comment.