Skip to content

Switch to wasm-timer #1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ 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" }
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"
Expand Down
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion core/src/protocols_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/src/protocols_handler/node_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
3 changes: 2 additions & 1 deletion core/src/protocols_handler/one_shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions core/src/transport/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions core/tests/raw_swarm_simult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>);
Expand Down
2 changes: 1 addition & 1 deletion misc/mdns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions misc/mdns/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions misc/mdns/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion protocols/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions protocols/identify/src/periodic_id_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion protocols/ping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions protocols/ping/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion protocols/ping/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
3 changes: 2 additions & 1 deletion src/bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down