adding some more temporary logs in peer_manager

This commit is contained in:
Ivan Folgueira Bande 2025-04-17 10:48:56 +02:00
parent 610b4f9e86
commit a8c2133647

View File

@ -506,8 +506,16 @@ proc getStreamByPeerIdAndProtocol*(
## Notice that the "Connection" type represents a stream within a transport connection
## (we will need to adapt this term.)
let remotePeerInfo = pm.getPeer(peerId)
debug "AAAAAAA getStreamByPeerIdAndProtocol",
peerId = peerId,
protocol = protocol,
remoteAgent = remotePeerInfo.agent,
remotePeerInfo = remotePeerInfo
let peerIdsMuxers: Table[PeerId, seq[Muxer]] = pm.switch.connManager.getConnections()
if not peerIdsMuxers.contains(peerId):
debug "AAAAAAA peerId not found in connManager", peerId = peerId
return err("peerId not found in connManager: " & $peerId)
let muxers = peerIdsMuxers[peerId]
@ -525,14 +533,19 @@ proc getStreamByPeerIdAndProtocol*(
)
if streamsOfInterest.len > 0:
debug "AAAAAAA open stream found, using it", peerId = peerId, protocol = protocol
## In theory there should be one stream per protocol. Then we just pick up the 1st
return ok(streamsOfInterest[0])
## There isn't still a stream. Let's dial to create one
let streamRes = await pm.dialPeer(peerId, protocol)
if streamRes.isNone():
debug "AAAAAAA dial failed, no connection to peer",
peerId = peerId, protocol = protocol
return err("getStreamByPeerIdProto no connection to peer: " & $peerId)
debug "AAAAAAA dialed stream", peerId = peerId, protocol = protocol
return ok(streamRes.get())
proc connectToRelayPeers*(pm: PeerManager) {.async.} =