mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 10:01:25 +00:00
{core,swarm}/: Don't require Transport: Clone
and take &mut
(#2529)
Previously `libp2p-swarm` required a `Transport` to be `Clone`. Methods on `Transport`, e.g. `Transport::dial` would take ownership, requiring e.g. a `Clone::clone` before calling `Transport::dial`. The requirement of `Transport` to be `Clone` is no longer needed in `libp2p-swarm`. E.g. concurrent dialing can be done without a clone per dial. This commit removes the requirement of `Clone` for `Transport` in `libp2p-swarm`. As a follow-up methods on `Transport` no longer take ownership, but instead a mutable reference (`&mut self`). On the one hand this simplifies `libp2p-swarm`, on the other it simplifies implementations of `Transport`.
This commit is contained in:
@ -276,7 +276,7 @@ mod tests {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
let bg_task = async_std::task::spawn(async move {
|
||||
let transport = TcpConfig::new();
|
||||
let mut transport = TcpConfig::new();
|
||||
|
||||
let mut listener = transport
|
||||
.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap())
|
||||
@ -321,7 +321,7 @@ mod tests {
|
||||
});
|
||||
|
||||
async_std::task::block_on(async move {
|
||||
let transport = TcpConfig::new();
|
||||
let mut transport = TcpConfig::new();
|
||||
|
||||
let socket = transport.dial(rx.await.unwrap()).unwrap().await.unwrap();
|
||||
let info = apply_outbound(socket, IdentifyProtocol, upgrade::Version::V1)
|
||||
|
Reference in New Issue
Block a user