mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-21 07:09:51 -05:00
mplex
This commit is contained in:
parent
9dc6228a2c
commit
f81a4cf629
@ -19,7 +19,7 @@ torut = { version = "0.1", default-features = false, features = [ "v3", "control
|
||||
tracing = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
libp2p = { version = "0.37", default-features = false, features = [ "yamux", "noise", "ping" ] }
|
||||
libp2p = { version = "0.37", default-features = false, features = [ "yamux", "noise", "ping", "mplex" ] }
|
||||
rand = "0.8"
|
||||
tempfile = "3"
|
||||
testcontainers = "0.12"
|
||||
|
@ -1,10 +1,11 @@
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::upgrade::Version;
|
||||
use libp2p::core::upgrade::{Version, SelectUpgrade};
|
||||
use libp2p::ping::{Ping, PingEvent, PingSuccess};
|
||||
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
|
||||
use libp2p::{identity, noise, yamux, Multiaddr, Swarm, Transport};
|
||||
use libp2p_tor::dial_only;
|
||||
use std::time::Duration;
|
||||
use libp2p::mplex::MplexConfig;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@ -55,6 +56,9 @@ async fn main() {
|
||||
/// Builds a new swarm that is capable of dialling onion address.
|
||||
fn new_swarm() -> Swarm<Ping> {
|
||||
let identity = identity::Keypair::generate_ed25519();
|
||||
let peer_id = identity.public().into_peer_id();
|
||||
|
||||
println!("peer id upon swarm setup: {}", peer_id);
|
||||
|
||||
SwarmBuilder::new(
|
||||
dial_only::TorConfig::new(9050)
|
||||
@ -67,12 +71,15 @@ fn new_swarm() -> Swarm<Ping> {
|
||||
)
|
||||
.into_authenticated(),
|
||||
)
|
||||
.multiplex(yamux::YamuxConfig::default())
|
||||
.multiplex(SelectUpgrade::new(
|
||||
yamux::YamuxConfig::default(),
|
||||
MplexConfig::new(),
|
||||
))
|
||||
.timeout(Duration::from_secs(20))
|
||||
.map(|(peer, muxer), _| (peer, StreamMuxerBox::new(muxer)))
|
||||
.boxed(),
|
||||
Ping::default(),
|
||||
identity.public().into_peer_id(),
|
||||
peer_id,
|
||||
)
|
||||
.executor(Box::new(|f| {
|
||||
tokio::spawn(f);
|
||||
|
@ -1,5 +1,5 @@
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::upgrade::Version;
|
||||
use libp2p::core::upgrade::{Version, SelectUpgrade};
|
||||
use libp2p::ping::{Ping, PingEvent, PingSuccess};
|
||||
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
|
||||
use libp2p::{identity, noise, yamux, Swarm, Transport, Multiaddr};
|
||||
@ -11,6 +11,7 @@ use std::time::Duration;
|
||||
use torut::control::AuthenticatedConn;
|
||||
use torut::onion::TorSecretKeyV3;
|
||||
use std::str::FromStr;
|
||||
use libp2p::mplex::MplexConfig;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@ -83,7 +84,10 @@ async fn new_swarm(key: TorSecretKeyV3) -> Swarm<Ping> {
|
||||
)
|
||||
.into_authenticated(),
|
||||
)
|
||||
.multiplex(yamux::YamuxConfig::default())
|
||||
.multiplex(SelectUpgrade::new(
|
||||
yamux::YamuxConfig::default(),
|
||||
MplexConfig::new(),
|
||||
))
|
||||
.timeout(Duration::from_secs(20))
|
||||
.map(|(peer, muxer), _| (peer, StreamMuxerBox::new(muxer)))
|
||||
.boxed(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user