Improve import layout
This commit is contained in:
parent
e7ac09cb94
commit
a4a0d79f6d
|
@ -8,27 +8,15 @@ from typing import (
|
||||||
|
|
||||||
import multiaddr
|
import multiaddr
|
||||||
|
|
||||||
from .host_interface import (
|
from libp2p.network.swarm import Swarm
|
||||||
IHost,
|
from libp2p.peer.id import ID
|
||||||
)
|
from libp2p.peer.peerinfo import PeerInfo
|
||||||
from libp2p.network.swarm import (
|
from libp2p.peer.peerstore import PeerStore
|
||||||
Swarm
|
|
||||||
)
|
from libp2p.network.stream.net_stream_interface import INetStream
|
||||||
from libp2p.peer.id import (
|
from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter
|
||||||
ID,
|
|
||||||
)
|
from .host_interface import IHost
|
||||||
from libp2p.peer.peerinfo import (
|
|
||||||
PeerInfo,
|
|
||||||
)
|
|
||||||
from libp2p.peer.peerstore import (
|
|
||||||
PeerStore,
|
|
||||||
)
|
|
||||||
from libp2p.network.stream.net_stream_interface import (
|
|
||||||
INetStream,
|
|
||||||
)
|
|
||||||
from libp2p.routing.kademlia.kademlia_peer_router import (
|
|
||||||
KadmeliaPeerRouter,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Upon host creation, host takes in options,
|
# Upon host creation, host takes in options,
|
||||||
# including the list of addresses on which to listen.
|
# including the list of addresses on which to listen.
|
||||||
|
|
|
@ -9,24 +9,13 @@ from typing import (
|
||||||
|
|
||||||
import multiaddr
|
import multiaddr
|
||||||
|
|
||||||
from libp2p.network.swarm import (
|
from libp2p.network.swarm import Swarm
|
||||||
Swarm
|
from libp2p.peer.id import ID
|
||||||
)
|
from libp2p.peer.peerinfo import PeerInfo
|
||||||
from libp2p.peer.id import (
|
from libp2p.peer.peerstore import PeerStore
|
||||||
ID,
|
|
||||||
)
|
from libp2p.network.stream.net_stream_interface import INetStream
|
||||||
from libp2p.peer.peerinfo import (
|
from libp2p.routing.kademlia.kademlia_peer_router import KadmeliaPeerRouter
|
||||||
PeerInfo,
|
|
||||||
)
|
|
||||||
from libp2p.peer.peerstore import (
|
|
||||||
PeerStore,
|
|
||||||
)
|
|
||||||
from libp2p.network.stream.net_stream_interface import (
|
|
||||||
INetStream,
|
|
||||||
)
|
|
||||||
from libp2p.routing.kademlia.kademlia_peer_router import (
|
|
||||||
KadmeliaPeerRouter,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class IHost(ABC):
|
class IHost(ABC):
|
||||||
|
|
|
@ -8,12 +8,11 @@ from typing import (
|
||||||
|
|
||||||
from multiaddr import Multiaddr
|
from multiaddr import Multiaddr
|
||||||
|
|
||||||
|
from libp2p.peer.id import ID
|
||||||
|
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
||||||
|
|
||||||
from .notifee_interface import INotifee
|
from .notifee_interface import INotifee
|
||||||
from .stream.net_stream import NetStream
|
from .stream.net_stream import NetStream
|
||||||
from libp2p.peer.id import (
|
|
||||||
ID,
|
|
||||||
)
|
|
||||||
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
|
||||||
|
|
||||||
|
|
||||||
class INetwork(ABC):
|
class INetwork(ABC):
|
||||||
|
|
|
@ -3,9 +3,10 @@ from abc import ABC, abstractmethod
|
||||||
from multiaddr import Multiaddr
|
from multiaddr import Multiaddr
|
||||||
|
|
||||||
from libp2p.network.network_interface import INetwork
|
from libp2p.network.network_interface import INetwork
|
||||||
from libp2p.network.stream.net_stream_interface import INetStream
|
|
||||||
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
||||||
|
|
||||||
|
from libp2p.network.stream.net_stream_interface import INetStream
|
||||||
|
|
||||||
|
|
||||||
class INotifee(ABC):
|
class INotifee(ABC):
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from .net_stream_interface import INetStream
|
|
||||||
from libp2p.stream_muxer.mplex.mplex_stream import MplexStream
|
|
||||||
from libp2p.stream_muxer.mplex.mplex import Mplex
|
from libp2p.stream_muxer.mplex.mplex import Mplex
|
||||||
|
from libp2p.stream_muxer.mplex.mplex_stream import MplexStream
|
||||||
|
|
||||||
|
from .net_stream_interface import INetStream
|
||||||
|
|
||||||
|
|
||||||
class NetStream(INetStream):
|
class NetStream(INetStream):
|
||||||
|
|
|
@ -10,10 +10,6 @@ from typing import (
|
||||||
|
|
||||||
from multiaddr import Multiaddr
|
from multiaddr import Multiaddr
|
||||||
|
|
||||||
from .network_interface import INetwork
|
|
||||||
from .notifee_interface import INotifee
|
|
||||||
from .connection.raw_connection import RawConnection
|
|
||||||
from .stream.net_stream import NetStream
|
|
||||||
from libp2p.peer.id import (
|
from libp2p.peer.id import (
|
||||||
ID,
|
ID,
|
||||||
id_b58_decode,
|
id_b58_decode,
|
||||||
|
@ -25,9 +21,15 @@ from libp2p.routing.interfaces import IPeerRouting
|
||||||
from libp2p.transport.upgrader import TransportUpgrader
|
from libp2p.transport.upgrader import TransportUpgrader
|
||||||
from libp2p.transport.transport_interface import ITransport
|
from libp2p.transport.transport_interface import ITransport
|
||||||
from libp2p.transport.listener_interface import IListener
|
from libp2p.transport.listener_interface import IListener
|
||||||
from libp2p.stream_muxer.mplex.mplex_stream import MplexStream
|
|
||||||
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
||||||
|
|
||||||
|
from libp2p.stream_muxer.mplex.mplex_stream import MplexStream
|
||||||
|
|
||||||
|
from .network_interface import INetwork
|
||||||
|
from .notifee_interface import INotifee
|
||||||
|
from .connection.raw_connection import RawConnection
|
||||||
|
from .stream.net_stream import NetStream
|
||||||
|
|
||||||
|
|
||||||
class Swarm(INetwork):
|
class Swarm(INetwork):
|
||||||
# pylint: disable=too-many-instance-attributes,cell-var-from-loop,too-many-arguments
|
# pylint: disable=too-many-instance-attributes,cell-var-from-loop,too-many-arguments
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
import hashlib
|
||||||
from typing import (
|
from typing import (
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
|
||||||
from Crypto.PublicKey.RSA import (
|
|
||||||
RsaKey,
|
|
||||||
)
|
|
||||||
import hashlib
|
|
||||||
import base58
|
import base58
|
||||||
|
|
||||||
import multihash
|
import multihash
|
||||||
|
|
||||||
|
from Crypto.PublicKey.RSA import RsaKey
|
||||||
|
|
||||||
# MaxInlineKeyLength is the maximum length a key can be for it to be inlined in
|
# MaxInlineKeyLength is the maximum length a key can be for it to be inlined in
|
||||||
# the peer ID.
|
# the peer ID.
|
||||||
# * When `len(pubKey.Bytes()) <= MaxInlineKeyLength`, the peer ID is the
|
# * When `len(pubKey.Bytes()) <= MaxInlineKeyLength`, the peer ID is the
|
||||||
|
|
|
@ -9,9 +9,9 @@ from typing import (
|
||||||
from multiaddr import Multiaddr
|
from multiaddr import Multiaddr
|
||||||
|
|
||||||
from .id import ID
|
from .id import ID
|
||||||
from .peerstore_interface import IPeerStore
|
|
||||||
from .peerdata import PeerData
|
from .peerdata import PeerData
|
||||||
from .peerinfo import PeerInfo
|
from .peerinfo import PeerInfo
|
||||||
|
from .peerstore_interface import IPeerStore
|
||||||
|
|
||||||
|
|
||||||
class PeerStore(IPeerStore):
|
class PeerStore(IPeerStore):
|
||||||
|
|
|
@ -5,9 +5,9 @@ from typing import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
from .addrbook_interface import IAddrBook
|
||||||
from .id import ID
|
from .id import ID
|
||||||
from .peerinfo import PeerInfo
|
from .peerinfo import PeerInfo
|
||||||
from .addrbook_interface import IAddrBook
|
|
||||||
from .peermetadata_interface import IPeerMetadata
|
from .peermetadata_interface import IPeerMetadata
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,6 @@ from libp2p.peer.id import (
|
||||||
from .pb import rpc_pb2
|
from .pb import rpc_pb2
|
||||||
from .pubsub import Pubsub
|
from .pubsub import Pubsub
|
||||||
from .pubsub_router_interface import IPubsubRouter
|
from .pubsub_router_interface import IPubsubRouter
|
||||||
from libp2p.network.stream.net_stream_interface import (
|
|
||||||
INetStream,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FloodSub(IPubsubRouter):
|
class FloodSub(IPubsubRouter):
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from ast import literal_eval
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
from typing import (
|
from typing import (
|
||||||
|
@ -9,8 +10,6 @@ from typing import (
|
||||||
Sequence,
|
Sequence,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ast import literal_eval
|
|
||||||
|
|
||||||
from libp2p.peer.id import (
|
from libp2p.peer.id import (
|
||||||
ID,
|
ID,
|
||||||
id_b58_decode,
|
id_b58_decode,
|
||||||
|
|
|
@ -10,21 +10,14 @@ from typing import (
|
||||||
|
|
||||||
from lru import LRU
|
from lru import LRU
|
||||||
|
|
||||||
|
from libp2p.host.host_interface import IHost
|
||||||
|
from libp2p.peer.id import ID
|
||||||
|
|
||||||
|
from libp2p.network.stream.net_stream_interface import INetStream
|
||||||
|
|
||||||
from .pb import rpc_pb2
|
from .pb import rpc_pb2
|
||||||
from .pubsub_notifee import PubsubNotifee
|
from .pubsub_notifee import PubsubNotifee
|
||||||
from .pubsub_router_interface import (
|
from .pubsub_router_interface import IPubsubRouter
|
||||||
IPubsubRouter,
|
|
||||||
)
|
|
||||||
from libp2p.host.host_interface import (
|
|
||||||
IHost,
|
|
||||||
)
|
|
||||||
from libp2p.peer.id import (
|
|
||||||
ID,
|
|
||||||
)
|
|
||||||
from libp2p.network.stream.net_stream_interface import (
|
|
||||||
INetStream,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_msg_id(msg: rpc_pb2.Message) -> Tuple[bytes, bytes]:
|
def get_msg_id(msg: rpc_pb2.Message) -> Tuple[bytes, bytes]:
|
||||||
|
|
|
@ -5,21 +5,12 @@ from typing import (
|
||||||
|
|
||||||
from multiaddr import Multiaddr
|
from multiaddr import Multiaddr
|
||||||
|
|
||||||
from libp2p.peer.id import (
|
from libp2p.peer.id import ID
|
||||||
ID,
|
from libp2p.network.network_interface import INetwork
|
||||||
)
|
from libp2p.network.notifee_interface import INotifee
|
||||||
from libp2p.stream_muxer.muxed_connection_interface import (
|
from libp2p.stream_muxer.muxed_connection_interface import IMuxedConn
|
||||||
IMuxedConn,
|
|
||||||
)
|
from libp2p.network.stream.net_stream_interface import INetStream
|
||||||
from libp2p.network.notifee_interface import (
|
|
||||||
INotifee,
|
|
||||||
)
|
|
||||||
from libp2p.network.network_interface import (
|
|
||||||
INetwork,
|
|
||||||
)
|
|
||||||
from libp2p.network.stream.net_stream_interface import (
|
|
||||||
INetStream,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PubsubNotifee(INotifee):
|
class PubsubNotifee(INotifee):
|
||||||
|
|
|
@ -3,11 +3,10 @@ from typing import (
|
||||||
List,
|
List,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from libp2p.peer.id import ID
|
||||||
|
|
||||||
from .pb import rpc_pb2
|
from .pb import rpc_pb2
|
||||||
from .pubsub import Pubsub
|
from .pubsub import Pubsub
|
||||||
from libp2p.peer.id import (
|
|
||||||
ID,
|
|
||||||
)
|
|
||||||
|
|
||||||
class IPubsubRouter(ABC):
|
class IPubsubRouter(ABC):
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,8 @@ from typing import (
|
||||||
Iterable,
|
Iterable,
|
||||||
)
|
)
|
||||||
|
|
||||||
from libp2p.peer.id import (
|
from libp2p.peer.id import ID
|
||||||
ID,
|
from libp2p.peer.peerinfo import PeerInfo
|
||||||
)
|
|
||||||
from libp2p.peer.peerinfo import (
|
|
||||||
PeerInfo,
|
|
||||||
)
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user