mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Update networking code to libp2p 0.14 (#4383)
* Entirely update substrate-telemetry to futures 0.3 * Add a Closed error * Update to libp2p 0.14 * More work * More work * More work * More work * Fix warnings * Remove unwrap() * Work on tests fixing * Fix network tests * Fix external network tests * Update libp2p and restore Yamux in discovery test * Ignore DNS if initializatio nfails * Restore variables ordering * Forgot browser-utils * Fix downfall after merge * Fix tests
This commit is contained in:
committed by
Gavin Wood
parent
6e572a9477
commit
ca997cf1e4
@@ -20,7 +20,6 @@ use crate::{
|
||||
};
|
||||
use crate::{ExHashT, specialization::NetworkSpecialization};
|
||||
use crate::protocol::{CustomMessageOutcome, Protocol};
|
||||
use futures::prelude::*;
|
||||
use libp2p::NetworkBehaviour;
|
||||
use libp2p::core::{Multiaddr, PeerId, PublicKey};
|
||||
use libp2p::kad::record;
|
||||
@@ -29,7 +28,7 @@ use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox};
|
||||
use log::{debug, warn};
|
||||
use sp_consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}};
|
||||
use sp_runtime::{traits::{Block as BlockT, NumberFor}, Justification};
|
||||
use std::iter;
|
||||
use std::{iter, task::Context, task::Poll};
|
||||
use void;
|
||||
|
||||
/// General behaviour of the network. Combines all protocols together.
|
||||
@@ -59,7 +58,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
|
||||
impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Behaviour<B, S, H> {
|
||||
/// Builds a new `Behaviour`.
|
||||
pub fn new(
|
||||
pub async fn new(
|
||||
substrate: Protocol<B, S, H>,
|
||||
user_agent: String,
|
||||
local_public_key: PublicKey,
|
||||
@@ -75,7 +74,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Behaviour<B, S, H> {
|
||||
known_addresses,
|
||||
enable_mdns,
|
||||
allow_private_ipv4
|
||||
),
|
||||
).await,
|
||||
events: Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -212,11 +211,11 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> NetworkBehaviourEventPr
|
||||
}
|
||||
|
||||
impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Behaviour<B, S, H> {
|
||||
fn poll<TEv>(&mut self) -> Async<NetworkBehaviourAction<TEv, BehaviourOut<B>>> {
|
||||
fn poll<TEv>(&mut self, _: &mut Context) -> Poll<NetworkBehaviourAction<TEv, BehaviourOut<B>>> {
|
||||
if !self.events.is_empty() {
|
||||
return Async::Ready(NetworkBehaviourAction::GenerateEvent(self.events.remove(0)))
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(self.events.remove(0)))
|
||||
}
|
||||
|
||||
Async::NotReady
|
||||
Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user