Skip to content

Commit

Permalink
Revert "*: Enable libp2p to run via wasm32-unknown-unknown in the bro…
Browse files Browse the repository at this point in the history
…wser (libp2p#2320)"

This reverts commit ff5d455.
  • Loading branch information
divagant-martian committed Feb 9, 2022
1 parent 4eb3d15 commit 209ca13
Show file tree
Hide file tree
Showing 39 changed files with 74 additions and 283 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
- `libp2p-swarm-derive`
- `libp2p-swarm`
- `libp2p-websocket`
- Forward `wasm-bindgen` feature to `futures-timer`, `instant`, `parking_lot`, `getrandom/js` and `rand/wasm-bindgen`.

## Version 0.40.0 [2021-11-01]

Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ either = "1.5"
fnv = "1.0"
futures = { version = "0.3.1", features = ["executor", "thread-pool"] }
futures-timer = "3"
instant = "0.1.11"
lazy_static = "1.2"
libsecp256k1 = { version = "0.7.0", optional = true }
log = "0.4"
Expand Down Expand Up @@ -54,6 +53,7 @@ rmp-serde = "1.0"
multihash = { version = "0.16", default-features = false, features = ["arb"] }
quickcheck = "0.9.0"
rand07 = { package = "rand", version = "0.7" }
wasm-timer = "0.2"

[build-dependencies]
prost-build = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion core/src/peer_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::identity::error::SigningError;
use crate::identity::Keypair;
use crate::signed_envelope::SignedEnvelope;
use crate::{peer_record_proto, signed_envelope, Multiaddr, PeerId};
use instant::SystemTime;
use std::convert::TryInto;
use std::fmt;
use std::time::SystemTime;

const PAYLOAD_TYPE: &str = "/libp2p/routing-state-record";
const DOMAIN_SEP: &str = "libp2p-routing-state";
Expand Down
1 change: 1 addition & 0 deletions protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fnv = "1.0.7"
futures = "0.3.5"
rand = "0.7.3"
asynchronous-codec = "0.6"
wasm-timer = "0.2.4"
unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] }
log = "0.4.11"
sha2 = "0.10.0"
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

//! Data structure for efficiently storing known back-off's when pruning peers.
use crate::topic::TopicHash;
use instant::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);
Expand Down
8 changes: 4 additions & 4 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use log::{debug, error, trace, warn};
use prometheus_client::registry::Registry;
use prost::Message;
use rand::{seq::SliceRandom, thread_rng};
use wasm_timer::{Instant, Interval};

use instant::Instant;
use libp2p_core::{
connection::ConnectionId, identity::Keypair, multiaddr::Protocol::Ip4,
multiaddr::Protocol::Ip6, ConnectedPoint, Multiaddr, PeerId,
Expand All @@ -46,6 +46,7 @@ use libp2p_swarm::{
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
};

use crate::backoff::BackoffStorage;
use crate::config::{GossipsubConfig, ValidationMode};
use crate::error::{PublishError, SubscriptionError, ValidationError};
use crate::gossip_promises::GossipPromises;
Expand All @@ -63,7 +64,6 @@ use crate::types::{
GossipsubSubscriptionAction, MessageAcceptance, MessageId, PeerInfo, RawGossipsubMessage,
};
use crate::types::{GossipsubRpc, PeerConnections, PeerKind};
use crate::{backoff::BackoffStorage, interval::Interval};
use crate::{rpc_proto, TopicScoreParams};
use std::{cmp::Ordering::Equal, fmt::Debug};

Expand Down Expand Up @@ -439,8 +439,8 @@ where
config.backoff_slack(),
),
mcache: MessageCache::new(config.history_gossip(), config.history_length()),
heartbeat: Interval::new_initial(
config.heartbeat_initial_delay(),
heartbeat: Interval::new_at(
Instant::now() + config.heartbeat_initial_delay(),
config.heartbeat_interval(),
),
heartbeat_ticks: 0,
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/gossip_promises.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use crate::error::ValidationError;
use crate::peer_score::RejectReason;
use crate::MessageId;
use instant::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)]
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::types::{GossipsubRpc, PeerKind, RawGossipsubMessage};
use asynchronous_codec::Framed;
use futures::prelude::*;
use futures::StreamExt;
use instant::Instant;
use libp2p_core::upgrade::{InboundUpgrade, NegotiationError, OutboundUpgrade, UpgradeError};
use libp2p_swarm::protocols_handler::{
KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol,
Expand All @@ -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;
Expand Down
209 changes: 0 additions & 209 deletions protocols/gossipsub/src/interval.rs

This file was deleted.

1 change: 0 additions & 1 deletion protocols/gossipsub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ mod behaviour;
mod config;
mod gossip_promises;
mod handler;
mod interval;
mod mcache;
pub mod metrics;
mod peer_score;
Expand Down
3 changes: 1 addition & 2 deletions protocols/gossipsub/src/peer_score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
use crate::metrics::{Metrics, Penalty};
use crate::time_cache::TimeCache;
use crate::{MessageId, TopicHash};
use instant::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 std::time::{Duration, Instant};

mod params;
use crate::error::ValidationError;
Expand Down
3 changes: 1 addition & 2 deletions protocols/gossipsub/src/time_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
//! This implements a time-based LRU cache for checking gossipsub message duplicates.

use fnv::FnvHashMap;
use instant::Instant;
use std::collections::hash_map::{
self,
Entry::{Occupied, Vacant},
};
use std::collections::VecDeque;
use std::time::Duration;
use std::time::{Duration, Instant};

struct ExpiringElement<Element> {
/// The element that expires
Expand Down
1 change: 1 addition & 0 deletions protocols/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ log = "0.4.1"
lru = "0.7.2"
prost = "0.9"
smallvec = "1.6.1"
wasm-timer = "0.2"

[dev-dependencies]
async-std = "1.6.2"
Expand Down
Loading

0 comments on commit 209ca13

Please sign in to comment.