Skip to content
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

Add ExpandedSwarm #1046

Merged
merged 2 commits into from
Apr 7, 2019
Merged

Add ExpandedSwarm #1046

merged 2 commits into from
Apr 7, 2019

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Apr 4, 2019

Turns Swarm into a type Swarm<...> = ExpandedSwarm<...> where ExpandedSwarm has a lot more template parameters.

Unfortunately Rust still has a lot of limitations when it comes to bounds. I got blocked in Substrate because of some combination of requirements that wasn't possible to satisfy in a struct declaration. This PR makes it possible to use the swarm in ways that weren't possible by removing the mandatory where TBehaviour: NetworkBehaviour requirement from Swarm.

@ghost ghost assigned tomaka Apr 4, 2019
@ghost ghost added the in progress label Apr 4, 2019
Copy link
Contributor

@twittner twittner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having similarly named types RawSwarm, ExpandedSwarm and Swarm is certainly not optimal. I wonder if we would be better off without the NetworkBehaviour trait and instead have users consume events from the swarm stream and providing them with a command channel for the swarm?

@tomaka
Copy link
Member Author

tomaka commented Apr 5, 2019

better off without the NetworkBehaviour trait and instead have users consume events from the swarm stream and providing them with a command channel for the swarm?

From my understanding that basically means using the RawSwarm directly.
The NetworkBehaviour trait is mostly for composability, so that we can provide behaviours and let the user combine behaviours together in an easy way.

@tomaka tomaka merged commit 480cf38 into libp2p:master Apr 7, 2019
@ghost ghost removed the in progress label Apr 7, 2019
@tomaka tomaka deleted the expanded-swarm branch April 7, 2019 21:34
@tomaka tomaka mentioned this pull request Apr 15, 2019
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants