diff --git a/protocols/gossipsub/src/backoff.rs b/protocols/gossipsub/src/backoff.rs index b80f534e9fc5..c10814d289eb 100644 --- a/protocols/gossipsub/src/backoff.rs +++ b/protocols/gossipsub/src/backoff.rs @@ -20,13 +20,13 @@ //! Data structure for efficiently storing known back-off's when pruning peers. use crate::topic::TopicHash; -use wasm_timer::Instant; use libp2p_core::PeerId; use std::collections::{ hash_map::{Entry, HashMap}, HashSet, }; use std::time::Duration; +use wasm_timer::Instant; #[derive(Copy, Clone)] struct HeartbeatIndex(usize); diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index ba7804369c6a..38fc527a2d76 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -36,7 +36,6 @@ use prometheus_client::registry::Registry; use prost::Message; use rand::{seq::SliceRandom, thread_rng}; -use wasm_timer::Instant; use libp2p_core::{ connection::ConnectionId, identity::Keypair, multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, ConnectedPoint, Multiaddr, PeerId, @@ -45,6 +44,7 @@ use libp2p_swarm::{ dial_opts::{self, DialOpts}, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters, }; +use wasm_timer::Instant; use crate::backoff::BackoffStorage; use crate::config::{GossipsubConfig, ValidationMode}; diff --git a/protocols/gossipsub/src/gossip_promises.rs b/protocols/gossipsub/src/gossip_promises.rs index e17eefd28d08..40ea89a0629a 100644 --- a/protocols/gossipsub/src/gossip_promises.rs +++ b/protocols/gossipsub/src/gossip_promises.rs @@ -21,10 +21,10 @@ use crate::error::ValidationError; use crate::peer_score::RejectReason; use crate::MessageId; -use wasm_timer::Instant; use libp2p_core::PeerId; use log::debug; use std::collections::HashMap; +use wasm_timer::Instant; /// Tracks recently sent `IWANT` messages and checks if peers respond to them. #[derive(Default)] diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index b17d4e57434a..b2869d9e9c9e 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -25,7 +25,6 @@ use crate::types::{GossipsubRpc, PeerKind, RawGossipsubMessage}; use asynchronous_codec::Framed; use futures::prelude::*; use futures::StreamExt; -use wasm_timer::Instant; use libp2p_core::upgrade::{InboundUpgrade, NegotiationError, OutboundUpgrade, UpgradeError}; use libp2p_swarm::protocols_handler::{ KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol, @@ -40,6 +39,7 @@ use std::{ task::{Context, Poll}, time::Duration, }; +use wasm_timer::Instant; /// The initial time (in seconds) we set the keep alive for protocol negotiations to occur. const INITIAL_KEEP_ALIVE: u64 = 30; diff --git a/protocols/gossipsub/src/peer_score.rs b/protocols/gossipsub/src/peer_score.rs index bd05051f2490..d8d0650daf70 100644 --- a/protocols/gossipsub/src/peer_score.rs +++ b/protocols/gossipsub/src/peer_score.rs @@ -24,12 +24,12 @@ use crate::metrics::{Metrics, Penalty}; use crate::time_cache::TimeCache; use crate::{MessageId, TopicHash}; -use wasm_timer::Instant; use libp2p_core::PeerId; use log::{debug, trace, warn}; use std::collections::{hash_map, HashMap, HashSet}; use std::net::IpAddr; use std::time::Duration; +use wasm_timer::Instant; mod params; use crate::error::ValidationError; diff --git a/protocols/gossipsub/src/time_cache.rs b/protocols/gossipsub/src/time_cache.rs index 0f8b18646528..63a78e951f3f 100644 --- a/protocols/gossipsub/src/time_cache.rs +++ b/protocols/gossipsub/src/time_cache.rs @@ -21,13 +21,13 @@ //! This implements a time-based LRU cache for checking gossipsub message duplicates. use fnv::FnvHashMap; -use wasm_timer::Instant; use std::collections::hash_map::{ self, Entry::{Occupied, Vacant}, }; use std::collections::VecDeque; use std::time::Duration; +use wasm_timer::Instant; struct ExpiringElement { /// The element that expires