mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
refactor(plaintext): rename symbols to follow naming convention
Related: #2217. Pull-Request: #4535.
This commit is contained in:
@ -24,7 +24,7 @@ use libp2p_core::transport::{MemoryTransport, Transport};
|
||||
use libp2p_dcutr as dcutr;
|
||||
use libp2p_identity as identity;
|
||||
use libp2p_identity::PeerId;
|
||||
use libp2p_plaintext::PlainText2Config;
|
||||
use libp2p_plaintext as plaintext;
|
||||
use libp2p_relay as relay;
|
||||
use libp2p_swarm::{NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent};
|
||||
use libp2p_swarm_test::SwarmExt as _;
|
||||
@ -111,8 +111,7 @@ fn build_relay() -> Swarm<relay::Behaviour> {
|
||||
|
||||
fn build_client() -> Swarm<Client> {
|
||||
let local_key = identity::Keypair::generate_ed25519();
|
||||
let local_public_key = local_key.public();
|
||||
let local_peer_id = local_public_key.to_peer_id();
|
||||
let local_peer_id = local_key.public().to_peer_id();
|
||||
|
||||
let (relay_transport, behaviour) = relay::client::new(local_peer_id);
|
||||
|
||||
@ -120,7 +119,7 @@ fn build_client() -> Swarm<Client> {
|
||||
.or_transport(MemoryTransport::default())
|
||||
.or_transport(libp2p_tcp::async_io::Transport::default())
|
||||
.upgrade(Version::V1)
|
||||
.authenticate(PlainText2Config { local_public_key })
|
||||
.authenticate(plaintext::Config::new(&local_key))
|
||||
.multiplex(libp2p_yamux::Config::default())
|
||||
.boxed();
|
||||
|
||||
|
@ -30,9 +30,8 @@ use libp2p_core::transport::{Boxed, MemoryTransport, Transport};
|
||||
use libp2p_core::upgrade;
|
||||
use libp2p_identity as identity;
|
||||
use libp2p_identity::PeerId;
|
||||
use libp2p_identity::PublicKey;
|
||||
use libp2p_ping as ping;
|
||||
use libp2p_plaintext::PlainText2Config;
|
||||
use libp2p_plaintext as plaintext;
|
||||
use libp2p_relay as relay;
|
||||
use libp2p_swarm::{NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent};
|
||||
use std::time::Duration;
|
||||
@ -307,10 +306,9 @@ fn reuse_connection() {
|
||||
|
||||
fn build_relay() -> Swarm<Relay> {
|
||||
let local_key = identity::Keypair::generate_ed25519();
|
||||
let local_public_key = local_key.public();
|
||||
let local_peer_id = local_public_key.to_peer_id();
|
||||
let local_peer_id = local_key.public().to_peer_id();
|
||||
|
||||
let transport = upgrade_transport(MemoryTransport::default().boxed(), local_public_key);
|
||||
let transport = upgrade_transport(MemoryTransport::default().boxed(), &local_key);
|
||||
|
||||
SwarmBuilder::with_async_std_executor(
|
||||
transport,
|
||||
@ -331,13 +329,12 @@ fn build_relay() -> Swarm<Relay> {
|
||||
|
||||
fn build_client() -> Swarm<Client> {
|
||||
let local_key = identity::Keypair::generate_ed25519();
|
||||
let local_public_key = local_key.public();
|
||||
let local_peer_id = local_public_key.to_peer_id();
|
||||
let local_peer_id = local_key.public().to_peer_id();
|
||||
|
||||
let (relay_transport, behaviour) = relay::client::new(local_peer_id);
|
||||
let transport = upgrade_transport(
|
||||
OrTransport::new(relay_transport, MemoryTransport::default()).boxed(),
|
||||
local_public_key,
|
||||
&local_key,
|
||||
);
|
||||
|
||||
SwarmBuilder::with_async_std_executor(
|
||||
@ -353,14 +350,14 @@ fn build_client() -> Swarm<Client> {
|
||||
|
||||
fn upgrade_transport<StreamSink>(
|
||||
transport: Boxed<StreamSink>,
|
||||
local_public_key: PublicKey,
|
||||
identity: &identity::Keypair,
|
||||
) -> Boxed<(PeerId, StreamMuxerBox)>
|
||||
where
|
||||
StreamSink: AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||||
{
|
||||
transport
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(PlainText2Config { local_public_key })
|
||||
.authenticate(plaintext::Config::new(identity))
|
||||
.multiplex(libp2p_yamux::Config::default())
|
||||
.boxed()
|
||||
}
|
||||
|
Reference in New Issue
Block a user