mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 00:17:56 +00:00
Update libp2p to 0.16 (#4928)
* Update libp2p to 0.16
* Actually update to libp2p 0.16 🤦
* Fix missed updates
* Fix peerset tests
This commit is contained in:
@@ -38,7 +38,14 @@ use libp2p::{
|
||||
upgrade::{InboundUpgrade, ReadOneError, UpgradeInfo, Negotiated},
|
||||
upgrade::{DeniedUpgrade, read_one, write_one}
|
||||
},
|
||||
swarm::{NetworkBehaviour, NetworkBehaviourAction, OneShotHandler, PollParameters, SubstreamProtocol}
|
||||
swarm::{
|
||||
NegotiatedSubstream,
|
||||
NetworkBehaviour,
|
||||
NetworkBehaviourAction,
|
||||
OneShotHandler,
|
||||
PollParameters,
|
||||
SubstreamProtocol
|
||||
}
|
||||
};
|
||||
use prost::Message;
|
||||
use sp_runtime::{generic::BlockId, traits::{Block, Header, One, Zero}};
|
||||
@@ -111,20 +118,17 @@ impl Config {
|
||||
}
|
||||
|
||||
/// The block request handling behaviour.
|
||||
pub struct BlockRequests<T, B: Block> {
|
||||
pub struct BlockRequests<B: Block> {
|
||||
/// This behaviour's configuration.
|
||||
config: Config,
|
||||
/// Blockchain client.
|
||||
chain: Arc<dyn Client<B>>,
|
||||
/// Futures sending back the block request response.
|
||||
outgoing: FuturesUnordered<BoxFuture<'static, ()>>,
|
||||
/// Type witness term.
|
||||
_marker: std::marker::PhantomData<T>
|
||||
}
|
||||
|
||||
impl<T, B> BlockRequests<T, B>
|
||||
impl<B> BlockRequests<B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
B: Block,
|
||||
{
|
||||
pub fn new(cfg: Config, chain: Arc<dyn Client<B>>) -> Self {
|
||||
@@ -132,7 +136,6 @@ where
|
||||
config: cfg,
|
||||
chain,
|
||||
outgoing: FuturesUnordered::new(),
|
||||
_marker: std::marker::PhantomData
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,12 +246,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> NetworkBehaviour for BlockRequests<T, B>
|
||||
impl<B> NetworkBehaviour for BlockRequests<B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
B: Block
|
||||
{
|
||||
type ProtocolsHandler = OneShotHandler<T, Protocol, DeniedUpgrade, Request<Negotiated<T>>>;
|
||||
type ProtocolsHandler = OneShotHandler<Protocol, DeniedUpgrade, Request<NegotiatedSubstream>>;
|
||||
type OutEvent = Void;
|
||||
|
||||
fn new_handler(&mut self) -> Self::ProtocolsHandler {
|
||||
@@ -269,7 +271,7 @@ where
|
||||
fn inject_disconnected(&mut self, _peer: &PeerId, _info: ConnectedPoint) {
|
||||
}
|
||||
|
||||
fn inject_node_event(&mut self, peer: PeerId, Request(request, mut stream): Request<Negotiated<T>>) {
|
||||
fn inject_node_event(&mut self, peer: PeerId, Request(request, mut stream): Request<NegotiatedSubstream>) {
|
||||
match self.on_block_request(&peer, &request) {
|
||||
Ok(res) => {
|
||||
log::trace!("enqueueing block response {} for peer {} with {} blocks", res.id, peer, res.blocks.len());
|
||||
|
||||
Reference in New Issue
Block a user