mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 16:10:57 +00:00
resolve linting errors
This commit is contained in:
@ -7,13 +7,14 @@ import trio
|
|||||||
from libp2p.abc import ID, INetworkService, PeerInfo
|
from libp2p.abc import ID, INetworkService, PeerInfo
|
||||||
from libp2p.discovery.bootstrap.utils import validate_bootstrap_addresses
|
from libp2p.discovery.bootstrap.utils import validate_bootstrap_addresses
|
||||||
from libp2p.discovery.events.peerDiscovery import peerDiscovery
|
from libp2p.discovery.events.peerDiscovery import peerDiscovery
|
||||||
|
from libp2p.network.exceptions import SwarmException
|
||||||
from libp2p.peer.peerinfo import info_from_p2p_addr
|
from libp2p.peer.peerinfo import info_from_p2p_addr
|
||||||
from libp2p.peer.peerstore import PERMANENT_ADDR_TTL
|
from libp2p.peer.peerstore import PERMANENT_ADDR_TTL
|
||||||
from libp2p.network.exceptions import SwarmException
|
|
||||||
|
|
||||||
logger = logging.getLogger("libp2p.discovery.bootstrap")
|
logger = logging.getLogger("libp2p.discovery.bootstrap")
|
||||||
resolver = DNSResolver()
|
resolver = DNSResolver()
|
||||||
|
|
||||||
|
|
||||||
class BootstrapDiscovery:
|
class BootstrapDiscovery:
|
||||||
"""
|
"""
|
||||||
Bootstrap-based peer discovery for py-libp2p.
|
Bootstrap-based peer discovery for py-libp2p.
|
||||||
@ -193,7 +194,9 @@ class BootstrapDiscovery:
|
|||||||
)
|
)
|
||||||
# Even for existing peers, try to connect if not already connected
|
# Even for existing peers, try to connect if not already connected
|
||||||
if peer_info.peer_id not in self.swarm.connections:
|
if peer_info.peer_id not in self.swarm.connections:
|
||||||
logger.debug("Starting parallel connection attempt for existing peer...")
|
logger.debug(
|
||||||
|
"Starting parallel connection attempt for existing peer..."
|
||||||
|
)
|
||||||
# Use nursery for parallel connection attempt (non-blocking)
|
# Use nursery for parallel connection attempt (non-blocking)
|
||||||
try:
|
try:
|
||||||
async with trio.open_nursery() as connection_nursery:
|
async with trio.open_nursery() as connection_nursery:
|
||||||
@ -248,7 +251,7 @@ class BootstrapDiscovery:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Use swarm.dial_peer to connect using stored addresses
|
# Use swarm.dial_peer to connect using stored addresses
|
||||||
connection = await self.swarm.dial_peer(peer_id)
|
await self.swarm.dial_peer(peer_id)
|
||||||
|
|
||||||
# Calculate connection time
|
# Calculate connection time
|
||||||
connection_time = trio.current_time() - connection_start_time
|
connection_time = trio.current_time() - connection_start_time
|
||||||
|
|||||||
Reference in New Issue
Block a user