mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 18:41:22 +00:00
*: Enable libp2p to run via wasm32-unknown-unknown in the browser (#2320)
Changes needed to get libp2p to run via `wasm32-unknown-unknown` in the browser (both main thread and inside web workers). Replaces wasm-timer with futures-timer and instant. Co-authored-by: Oliver Wangler <oliver@wngr.de>
This commit is contained in:
@ -34,8 +34,8 @@ use futures::StreamExt;
|
||||
use log::{debug, error, trace, warn};
|
||||
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,
|
||||
@ -45,7 +45,6 @@ use libp2p_swarm::{
|
||||
NotifyHandler, PollParameters,
|
||||
};
|
||||
|
||||
use crate::backoff::BackoffStorage;
|
||||
use crate::config::{GossipsubConfig, ValidationMode};
|
||||
use crate::error::{PublishError, SubscriptionError, ValidationError};
|
||||
use crate::gossip_promises::GossipPromises;
|
||||
@ -62,6 +61,7 @@ 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};
|
||||
|
||||
@ -406,8 +406,8 @@ where
|
||||
config.backoff_slack(),
|
||||
),
|
||||
mcache: MessageCache::new(config.history_gossip(), config.history_length()),
|
||||
heartbeat: Interval::new_at(
|
||||
Instant::now() + config.heartbeat_initial_delay(),
|
||||
heartbeat: Interval::new_initial(
|
||||
config.heartbeat_initial_delay(),
|
||||
config.heartbeat_interval(),
|
||||
),
|
||||
heartbeat_ticks: 0,
|
||||
|
Reference in New Issue
Block a user