Ping wasn't working anymore (#979)

* Fix ping

* Update protocols/ping/src/handler.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>
This commit is contained in:
Pierre Krieger
2019-02-27 18:12:51 +01:00
committed by GitHub
parent c3670c4bf3
commit 2e57282efd
2 changed files with 139 additions and 3 deletions

View File

@ -32,10 +32,11 @@
//! When a ping succeeds, a `PingSuccess` event is generated, indicating the time the ping took.
pub mod protocol;
pub mod handler;
use futures::prelude::*;
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p_core::protocols_handler::{OneShotHandler, ProtocolsHandler};
use libp2p_core::protocols_handler::ProtocolsHandler;
use libp2p_core::{Multiaddr, PeerId};
use std::{marker::PhantomData, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
@ -83,11 +84,11 @@ impl<TSubstream> NetworkBehaviour for Ping<TSubstream>
where
TSubstream: AsyncRead + AsyncWrite,
{
type ProtocolsHandler = OneShotHandler<TSubstream, protocol::Ping, protocol::Ping, protocol::PingOutput>;
type ProtocolsHandler = handler::PingHandler<TSubstream>;
type OutEvent = PingEvent;
fn new_handler(&mut self) -> Self::ProtocolsHandler {
OneShotHandler::default()
handler::PingHandler::default()
}
fn addresses_of_peer(&mut self, _peer_id: &PeerId) -> Vec<Multiaddr> {