update libp2p (#4864)
## Issue Addressed updates libp2p to the latest version and uses the new `SwarmBuilder`. Superseeds https://github.com/sigp/lighthouse/pull/4695/ CC @mxinden I don't think we can use both `bandwidth_loggers` with the new syntax right?
This commit is contained in:
parent
8c28d175b8
commit
c6583bb5fa
485
Cargo.lock
generated
485
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -29,10 +29,10 @@ use libp2p::gossipsub::{
|
|||||||
self, IdentTopic as Topic, MessageAcceptance, MessageAuthenticity, MessageId, PublishError,
|
self, IdentTopic as Topic, MessageAcceptance, MessageAuthenticity, MessageId, PublishError,
|
||||||
TopicScoreParams,
|
TopicScoreParams,
|
||||||
};
|
};
|
||||||
use libp2p::identify;
|
|
||||||
use libp2p::multiaddr::{Multiaddr, Protocol as MProtocol};
|
use libp2p::multiaddr::{Multiaddr, Protocol as MProtocol};
|
||||||
use libp2p::swarm::{Swarm, SwarmBuilder, SwarmEvent};
|
use libp2p::swarm::{Swarm, SwarmEvent};
|
||||||
use libp2p::PeerId;
|
use libp2p::PeerId;
|
||||||
|
use libp2p::{identify, SwarmBuilder};
|
||||||
use slog::{crit, debug, info, o, trace, warn};
|
use slog::{crit, debug, info, o, trace, warn};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
@ -365,8 +365,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let (swarm, bandwidth) = {
|
// Set up the transport - tcp/quic with noise and mplex
|
||||||
// Set up the transport - tcp/ws with noise and mplex
|
|
||||||
let (transport, bandwidth) =
|
let (transport, bandwidth) =
|
||||||
build_transport(local_keypair.clone(), !config.disable_quic_support)
|
build_transport(local_keypair.clone(), !config.disable_quic_support)
|
||||||
.map_err(|e| format!("Failed to build transport: {:?}", e))?;
|
.map_err(|e| format!("Failed to build transport: {:?}", e))?;
|
||||||
@ -379,21 +378,21 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets up the libp2p connection limits
|
// sets up the libp2p swarm.
|
||||||
|
let swarm = SwarmBuilder::with_existing_identity(local_keypair)
|
||||||
(
|
.with_tokio()
|
||||||
SwarmBuilder::with_executor(
|
.with_other_transport(|_key| transport)
|
||||||
transport,
|
.expect("infalible")
|
||||||
behaviour,
|
.with_behaviour(|_| behaviour)
|
||||||
local_peer_id,
|
.expect("infalible")
|
||||||
Executor(executor),
|
.with_swarm_config(|_| {
|
||||||
|
libp2p::swarm::Config::with_executor(Executor(executor))
|
||||||
|
.with_notify_handler_buffer_size(
|
||||||
|
std::num::NonZeroUsize::new(7).expect("Not zero"),
|
||||||
)
|
)
|
||||||
.notify_handler_buffer_size(std::num::NonZeroUsize::new(7).expect("Not zero"))
|
.with_per_connection_event_buffer_size(4)
|
||||||
.per_connection_event_buffer_size(4)
|
})
|
||||||
.build(),
|
.build();
|
||||||
bandwidth,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut network = Network {
|
let mut network = Network {
|
||||||
swarm,
|
swarm,
|
||||||
|
@ -88,7 +88,7 @@ pub fn build_transport(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Enables DNS over the transport.
|
// Enables DNS over the transport.
|
||||||
let transport = libp2p::dns::TokioDnsConfig::system(transport)?.boxed();
|
let transport = libp2p::dns::tokio::Transport::system(transport)?.boxed();
|
||||||
|
|
||||||
Ok((transport, bandwidth))
|
Ok((transport, bandwidth))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user