connection_keep_alive() now returns KeepAlive (#899)

* connection_keep_alive() now returns Option<Instant>

* Use KeepAlive instead of Option<Instant>
This commit is contained in:
Pierre Krieger
2019-01-30 16:37:34 +01:00
committed by GitHub
parent bbf56c6371
commit 663ec7e8da
11 changed files with 100 additions and 58 deletions

View File

@ -21,7 +21,7 @@
use crate::protocol::{IdentifySender, IdentifyProtocolConfig};
use futures::prelude::*;
use libp2p_core::{
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
protocols_handler::{KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
upgrade::{DeniedUpgrade, InboundUpgrade, OutboundUpgrade}
};
use smallvec::SmallVec;
@ -90,8 +90,8 @@ where
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, _: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {}
#[inline]
fn connection_keep_alive(&self) -> bool {
false
fn connection_keep_alive(&self) -> KeepAlive {
KeepAlive::Now
}
#[inline]

View File

@ -21,7 +21,7 @@
use crate::protocol::{RemoteInfo, IdentifyProtocolConfig};
use futures::prelude::*;
use libp2p_core::{
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
protocols_handler::{KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
upgrade::{DeniedUpgrade, OutboundUpgrade}
};
use std::{io, marker::PhantomData, time::{Duration, Instant}};
@ -123,8 +123,12 @@ where
}
#[inline]
fn connection_keep_alive(&self) -> bool {
!self.first_id_happened
fn connection_keep_alive(&self) -> KeepAlive {
if self.first_id_happened {
KeepAlive::Now
} else {
KeepAlive::Forever
}
}
#[inline]