Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

why Listen "/p2p-circuit"? #102

Closed
zeigo opened this issue Apr 2, 2020 · 4 comments
Closed

why Listen "/p2p-circuit"? #102

zeigo opened this issue Apr 2, 2020 · 4 comments
Labels
kind/support A question or request for support

Comments

@zeigo
Copy link

zeigo commented Apr 2, 2020

I know Listen returns a listener, and when a relay peer sends STOP to my peer, listener.Accept() gets a conn. So, when will the conn open a stream or accept a stream? Why construct such a conn?

@Stebalien Stebalien added the kind/support A question or request for support label Apr 3, 2020
@Stebalien
Copy link
Member

Could you expand on that? I'm not sure what you're trying to ask.

@zeigo
Copy link
Author

zeigo commented Apr 3, 2020

Listening "/p2p-circuit" makes RelayListener.Accept() called. If a relay hop opens a stream for circuit relay to peer B, then sends STOP, B will call handleStopStream, and write a conn to chan incoming. RelayListener.Accept() will read this conn from chan incoming, send a SUCCESS back, and return the conn.
So, why doesn't handleStopStream send SUCCESS directly? What's the conn used for? It seems this issue #28 is about it, but I can't understand it.

@Stebalien
Copy link
Member

Ah. The "swarm" calls Accept here. At that point, the swarm will start accepting multiplexed streams off the connection here.

The circuit transport doesn't use the connections directly, it gives them to go-libp2p-swarm.

Note: #28 is a unrelated.

@Stebalien
Copy link
Member

FYI, we don't send "SUCCESS" in handleStopStream because we haven't really succeeded until the connection is actually accepted by the swarm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

2 participants