mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
added: logs
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
import logging
|
||||
from typing import (
|
||||
Optional,
|
||||
)
|
||||
|
||||
# logger = logging.getLogger("libp2p.network.swarm")
|
||||
from loguru import (
|
||||
logger,
|
||||
)
|
||||
from multiaddr import (
|
||||
Multiaddr,
|
||||
)
|
||||
@ -55,8 +58,6 @@ from .exceptions import (
|
||||
SwarmException,
|
||||
)
|
||||
|
||||
logger = logging.getLogger("libp2p.network.swarm")
|
||||
|
||||
|
||||
def create_default_stream_handler(network: INetworkService) -> StreamHandlerFn:
|
||||
async def stream_handler(stream: INetStream) -> None:
|
||||
@ -130,6 +131,7 @@ class Swarm(Service, INetworkService):
|
||||
:return: muxed connection
|
||||
"""
|
||||
if peer_id in self.connections:
|
||||
logger.info("WE ARE RETURNING, PEER ALREADAY EXISTS")
|
||||
# If muxed connection already exists for peer_id,
|
||||
# set muxed connection equal to existing muxed connection
|
||||
return self.connections[peer_id]
|
||||
@ -150,6 +152,7 @@ class Swarm(Service, INetworkService):
|
||||
# Try all known addresses
|
||||
for multiaddr in addrs:
|
||||
try:
|
||||
logger.info("HANDSHAKE GOING TO HAPPEN")
|
||||
return await self.dial_addr(multiaddr, peer_id)
|
||||
except SwarmException as e:
|
||||
exceptions.append(e)
|
||||
@ -224,8 +227,11 @@ class Swarm(Service, INetworkService):
|
||||
logger.debug("attempting to open a stream to peer %s", peer_id)
|
||||
|
||||
swarm_conn = await self.dial_peer(peer_id)
|
||||
logger.info("INETCONN CREATED")
|
||||
|
||||
net_stream = await swarm_conn.new_stream()
|
||||
logger.info("INETSTREAM CREATED")
|
||||
|
||||
logger.debug("successfully opened a stream to peer %s", peer_id)
|
||||
return net_stream
|
||||
|
||||
|
||||
Reference in New Issue
Block a user