-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream oriented instead of peer oriented #133
Comments
Actually, we don't have to send messages back on the same stream. While I'd prefer to do that, we can also just send them back on our outbound stream. The important part here is tracking our peer's streams independently. |
In principle it is more correct to use a stream oriented approach as it avoids a lot of pitfalls with disconnects, but it is a rather complex change. |
Hey @vyzo @Stebalien ! P.S. some discussion is here: https://discuss.libp2p.io/t/gossip-questions/257/6 |
To copy from that thread, TL;DR: It makes it simpler. In libp2p, we generally use one of two patterns:
In both cases, the peer opening the stream controls the stream. Pubsub falls into the second category. We aren't sending requests, so we aren't expecting replies. On the other hand, in message-protocols like this, we could just do both. That is, when we open a stream for sending, we could also spin up a listener on that stream to handle incoming messages. That way, the other side would get to decide what they want to do. The upside is that this would support non-multiplexed connections. But the rule "the stream opener controls the stream" is just a lot simpler and we don't expect the non-multiplexed case to be all that common. |
@Stebalien thanks for detailed explanation! I think I understand your point. However gossip appears to me like something between pattern 1 and pattern 2. Because there are What I finally did is I effectively muxed those 2 streams into a 'virtual' single stream. That looks strange as we already have full-duplex stream capability |
I'm talking about the request/reply pattern:
E.g., HTTP. The key part here is actively blocking for a response. However, with gossipsub,
You shouldn't need to do that. The protocol is designed to be message oriented so you should be able to model everything as sending and receiving messages. Really, you could open a new stream per message and receive messages on multiple streams. |
Routing is currently peer oriented but we can probably make it significantly more robust by making it stream oriented. That is, completely forget about peer IDs.
Instead, when we receive a stream from a peer:
Separately, when we notice that we have a connection to a peer, maintain at most one open stream to that peer where we:
This makes handling multiple connections/streams pretty trivial.
Problems with the current system:
The text was updated successfully, but these errors were encountered: