Switch to wasm-timer (#1071)

This commit is contained in:
Pierre Krieger
2019-04-25 15:08:06 +02:00
committed by GitHub
parent 9a525d5dea
commit ce4ca3cc75
20 changed files with 36 additions and 33 deletions

View File

@ -37,6 +37,7 @@ smallvec = "0.6"
tokio-codec = "0.1"
tokio-executor = "0.1"
tokio-io = "0.1"
wasm-timer = "0.1"
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
libp2p-dns = { version = "0.7.0", path = "./transports/dns" }
@ -44,9 +45,6 @@ libp2p-mdns = { version = "0.7.0", path = "./misc/mdns" }
libp2p-noise = { version = "0.5.0", path = "./protocols/noise" }
libp2p-tcp = { version = "0.7.0", path = "./transports/tcp" }
[target.'cfg(any(target_os = "emscripten", target_os = "unknown"))'.dependencies]
stdweb = { version = "0.4", default-features = false }
[dev-dependencies]
env_logger = "0.6.0"
rand = "0.6"

View File

@ -32,7 +32,7 @@ sha2 = "0.8.0"
smallvec = "0.6"
tokio-executor = "0.1.4"
tokio-io = "0.1"
tokio-timer = "0.2"
wasm-timer = "0.1"
unsigned-varint = "0.2"
void = "1"
zeroize = "0.5"
@ -51,7 +51,7 @@ rand = "0.6"
quickcheck = "0.8"
tokio = "0.1"
tokio-codec = "0.1"
tokio-timer = "0.2"
wasm-timer = "0.1"
assert_matches = "1.3"
tokio-mock-task = "0.1"

View File

@ -44,8 +44,9 @@ use crate::upgrade::{
UpgradeError,
};
use futures::prelude::*;
use std::{cmp::Ordering, error, fmt, time::Duration, time::Instant};
use std::{cmp::Ordering, error, fmt, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use wasm_timer::Instant;
pub use self::dummy::DummyProtocolsHandler;
pub use self::map_in::MapInEvent;

View File

@ -32,7 +32,7 @@ use crate::{
};
use futures::prelude::*;
use std::{error, fmt, time::Duration};
use tokio_timer::{Delay, Timeout};
use wasm_timer::{Delay, Timeout};
/// Prototype for a `NodeHandlerWrapper`.
pub struct NodeHandlerWrapperBuilder<TIntoProtoHandler> {

View File

@ -25,8 +25,9 @@ use crate::protocols_handler::{
use crate::upgrade::{InboundUpgrade, OutboundUpgrade};
use futures::prelude::*;
use smallvec::SmallVec;
use std::{error, marker::PhantomData, time::Duration, time::Instant};
use std::{error, marker::PhantomData, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use wasm_timer::Instant;
/// Implementation of `ProtocolsHandler` that opens a new substream for each individual message.
///

View File

@ -28,8 +28,8 @@ use crate::{Multiaddr, Transport, transport::{TransportError, ListenerEvent}};
use futures::{try_ready, Async, Future, Poll, Stream};
use log::debug;
use std::{error, fmt, time::Duration};
use tokio_timer::Timeout;
use tokio_timer::timeout::Error as TimeoutError;
use wasm_timer::Timeout;
use wasm_timer::timeout::Error as TimeoutError;
/// A `TransportTimeout` is a `Transport` that wraps another `Transport` and adds
/// timeouts to all inbound and outbound connection attempts.

View File

@ -29,8 +29,8 @@ use libp2p_core::protocols_handler::{
ProtocolsHandlerEvent,
ProtocolsHandlerUpgrErr
};
use std::{io, time::Duration, time::Instant};
use tokio_timer::Delay;
use std::{io, time::Duration};
use wasm_timer::{Delay, Instant};
// TODO: replace with DummyProtocolsHandler after https://github.com/servo/rust-smallvec/issues/139 ?
struct TestHandler<TSubstream>(std::marker::PhantomData<TSubstream>);

View File

@ -21,7 +21,7 @@ rand = "0.6"
smallvec = "0.6"
tokio-io = "0.1"
tokio-reactor = "0.1"
tokio-timer = "0.2"
wasm-timer = "0.1"
tokio-udp = "0.1"
void = "1.0"

View File

@ -25,9 +25,9 @@ use libp2p_core::protocols_handler::{DummyProtocolsHandler, ProtocolsHandler};
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p_core::{address_translation, Multiaddr, PeerId, multiaddr::Protocol};
use smallvec::SmallVec;
use std::{cmp, fmt, io, iter, marker::PhantomData, time::Duration, time::Instant};
use std::{cmp, fmt, io, iter, marker::PhantomData, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_timer::Delay;
use wasm_timer::{Delay, Instant};
/// A `NetworkBehaviour` for mDNS. Automatically discovers peers on the local network and adds
/// them to the topology.

View File

@ -23,9 +23,9 @@ use dns_parser::{Packet, RData};
use futures::{prelude::*, task};
use libp2p_core::{Multiaddr, PeerId};
use multiaddr::Protocol;
use std::{fmt, io, net::Ipv4Addr, net::SocketAddr, str, time::Duration, time::Instant};
use std::{fmt, io, net::Ipv4Addr, net::SocketAddr, str, time::Duration};
use tokio_reactor::Handle;
use tokio_timer::Interval;
use wasm_timer::{Instant, Interval};
use tokio_udp::UdpSocket;
pub use dns::MdnsResponseError;
@ -169,7 +169,7 @@ impl MdnsService {
}
}
Ok(Async::NotReady) => (),
_ => unreachable!("A tokio_timer::Interval never errors"), // TODO: is that true?
_ => unreachable!("A wasm_timer::Interval never errors"), // TODO: is that true?
};
// Flush the send buffer of the main socket.

View File

@ -21,7 +21,7 @@ protobuf = "2.3"
smallvec = "0.6"
tokio-codec = "0.1"
tokio-io = "0.1.0"
tokio-timer = "0.2.6"
wasm-timer = "0.1"
unsigned-varint = { version = "0.2.1", features = ["codec"] }
void = "1.0"

View File

@ -30,9 +30,9 @@ use libp2p_core::{
},
upgrade::{DeniedUpgrade, OutboundUpgrade}
};
use std::{io, marker::PhantomData, time::{Duration, Instant}};
use std::{io, marker::PhantomData, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_timer::{self, Delay};
use wasm_timer::{Delay, Instant};
use void::{Void, unreachable};
/// Delay between the moment we connect and the first time we identify.
@ -90,7 +90,7 @@ where
{
type InEvent = Void;
type OutEvent = PeriodicIdHandlerEvent;
type Error = tokio_timer::Error;
type Error = wasm_timer::Error;
type Substream = TSubstream;
type InboundProtocol = DeniedUpgrade;
type OutboundProtocol = IdentifyProtocolConfig;

View File

@ -27,7 +27,7 @@ rand = "0.6.0"
smallvec = "0.6"
tokio-codec = "0.1"
tokio-io = "0.1"
tokio-timer = "0.2.6"
wasm-timer = "0.1"
unsigned-varint = { version = "0.2.1", features = ["codec"] }
void = "1.0"

View File

@ -30,9 +30,9 @@ use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourActio
use libp2p_core::{protocols_handler::ProtocolsHandler, Multiaddr, PeerId};
use multihash::Multihash;
use smallvec::SmallVec;
use std::{error, marker::PhantomData, num::NonZeroUsize, time::Duration, time::Instant};
use std::{error, marker::PhantomData, num::NonZeroUsize, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_timer::Interval;
use wasm_timer::{Instant, Interval};
mod test;

View File

@ -32,8 +32,9 @@ use libp2p_core::protocols_handler::{
};
use libp2p_core::{upgrade, either::EitherOutput, InboundUpgrade, OutboundUpgrade, PeerId, upgrade::Negotiated};
use multihash::Multihash;
use std::{error, fmt, io, time::Duration, time::Instant};
use std::{error, fmt, io, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
use wasm_timer::Instant;
/// Protocol handler that handles Kademlia communications with the remote.
///

View File

@ -26,8 +26,8 @@
use crate::kbucket::KBucketsPeerId;
use futures::prelude::*;
use smallvec::SmallVec;
use std::{cmp::PartialEq, time::Duration, time::Instant};
use tokio_timer::Delay;
use std::{cmp::PartialEq, time::Duration};
use wasm_timer::{Delay, Instant};
/// State of a query iterative process.
///

View File

@ -20,7 +20,7 @@ parking_lot = "0.7"
rand = "0.6"
tokio-codec = "0.1"
tokio-io = "0.1"
tokio-timer = "0.2.6"
wasm-timer = "0.1"
void = "1.0"
[dev-dependencies]

View File

@ -27,10 +27,10 @@ use libp2p_core::protocols_handler::{
ProtocolsHandler,
ProtocolsHandlerUpgrErr,
};
use std::{error::Error, io, fmt, num::NonZeroU32, time::{Duration, Instant}};
use std::{error::Error, io, fmt, num::NonZeroU32, time::Duration};
use std::collections::VecDeque;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_timer::Delay;
use wasm_timer::{Delay, Instant};
use void::Void;
/// The configuration for outbound pings.

View File

@ -22,8 +22,9 @@ use futures::{prelude::*, future, try_ready};
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, upgrade::Negotiated};
use log::debug;
use rand::{distributions, prelude::*};
use std::{io, iter, time::Duration, time::Instant};
use std::{io, iter, time::Duration};
use tokio_io::{io as nio, AsyncRead, AsyncWrite};
use wasm_timer::Instant;
/// Represents a prototype for an upgrade to handle the ping protocol.
///

View File

@ -23,7 +23,8 @@ use futures::{prelude::*, try_ready};
use lazy_static::lazy_static;
use parking_lot::Mutex;
use smallvec::{smallvec, SmallVec};
use std::{cmp, io, io::Read, io::Write, sync::Arc, time::Duration, time::Instant};
use std::{cmp, io, io::Read, io::Write, sync::Arc, time::Duration};
use wasm_timer::Instant;
/// Wraps around a `Transport` and logs the bandwidth that goes through all the opened connections.
#[derive(Clone)]