-
Notifications
You must be signed in to change notification settings - Fork 0
Implement StreamMuxer trait for Connection #2
Conversation
melekes
commented
May 24, 2022
•
edited
Loading
edited
- StreamMuxer trait
- Authenticate peer via Noise (single data channel, which can be reused later; noise can be dropped afterwards)
- Write tests
- stream: allow reading after stream is closed webrtc-rs/sctp#14
Fixes: ``` error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement ```
to prevent adding new data channels
@tomaka could you please take a look at this when you have the time? Thanks. |
The multiple mutexes feel a bit dangerous to me, both in terms of deadlock and in terms of race conditions (what if another method is called between the moment a mutex is unlocked and the next one locked? is it ok everywhere?) |
Another point is that I would suggest keeping the single data stream implementation on the side. |
This is how it was done before. Unfortunately, I had to switch to multiple mutexes (futures::Mutex and std::Mutex) because I was not able to get both async and sync code to compile with just one (I've tried both futures::Mutex and std::sync::Mutex). If I use futures::Mutex, it works inside async future, but I had to poll it in sync code and I wasn't sure how it will play with the rest of the code (i.e. if polling future returns ready, but mutex is not ready, will the future returns ready next time it's called?). If I use std::sync::Mutex, I have problems when locking data across await, I believe. I can try again though. |
It's still possible to do with the new implementation. You get a |
actually it's supposed to be 3rd (ip, port, fingerprint, peer_id) but let's not assume anything
and reduce one in smoke tests
It turned out we actually don't need it. webrtc-rs lib will increase channel ID for us (on both ends on the connection). Also, extract `register_data_channel_open_handler` fn to reduce the amount of duplicated code.
based on new ice, sctp and data crates
Copied from melekes/libp2p-webrtc-direct#2. This code does not yet compiles because of `XWebRTC` protocol. if you want to see the working version, please visit https://github.com/melekes/libp2p-webrtc-direct.