Replies: 1 comment
-
        Issue Swarm Listen
 Issue Descriptionrefactor the swarm.listen() in rust-libp2p so that it returns a "listen_id" that Understanding the repositoryIssue researchSearching the swarm.listen() in the repo: $ grep -nr "swarm.listen()"                                                               i
protocols/gossipsub/tests/smoke.rs:124:    swarm.listen().with_memory_addr_external().await;
protocols/autonat/tests/test_client.rs:426:    let (_, multiaddr) = swarm.listen().await;Swarm struct signature:
 pub struct Swarm<TBehaviour>
where
    TBehaviour: NetworkBehaviourtrait SwarmExt:
 implementation signature:
 impl<B> SwarmExt for Swarm<B>
where
    B: NetworkBehaviour + Send,
    <B as NetworkBehaviour>::ToSwarm: Debugmethod signature:
 
 Question: Is this the correct crate to test?
 Solution Proposal:1. Define Listen ID:
 Definition is already in /core/src/transport: 250 /// The ID of a single listener.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct ListenerId(usize);
impl ListenerId {
    /// Creates a new `ListenerId`.
    pub fn next() -> Self {
        ListenerId(NEXT_LISTENER_ID.fetch_add(1, Ordering::SeqCst))
    }
}2. Modify swarm.listen() Method:
 fn listen(&mut self) -> ListenFuture<&mut Self> {
    ListenFuture {
add_memory_external: false,
                         add_tcp_external: false,
                         swarm: self,
    }
}
 QUESTION: is the same ListenID inside the swarm?3. Emit SwarmEvent::NewListenAddress Event:
 
 4. Introduce SwarmEvent::ListenSetupDone Event:
 In the SwarmEvent... QUESTION: Will these fields satisfy the requirement?/// One of the listeners notifies of the side effects and completition
ListenerSetupDone {
    /// The listener that notifies the setup.
    listener_id: ListenerId,
    /// The setup address that was generated on the setup.
    address: Multiaddr,
},
 5. Emit SwarmEvent::ListenSetupDone in a Poll Loop:
 6. Testing:
 Change checklist
 References/Sources | 
  
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, since the first issue was a bit complex I decide to go on the second issue which I could not find in the Open issues section but it describes the following:
"2. refactor the swarm.listen() in rust-libp2p so that it returns a "listen_id" that gets passed back with SwarmEvent::NewListenAddress as well as a new SwarmEvent::ListenSetupDone event so that you get notified of the side effects and completion of each .listen() call. "
So if I understand correctly I made a quite large document mostly for myself to understand the project the structure the issue and what to do. There are few questions named after #### Question
Beta Was this translation helpful? Give feedback.
All reactions