*: 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:
Max Inden
2021-10-30 12:41:30 +02:00
committed by GitHub
parent b8f0e44b27
commit ff5d455ccf
50 changed files with 365 additions and 86 deletions

View File

@@ -26,6 +26,7 @@ use crate::{RequestId, EMPTY_QUEUE_SHRINK_THRESHOLD};
pub use protocol::{ProtocolSupport, RequestProtocol, ResponseProtocol};
use futures::{channel::oneshot, future::BoxFuture, prelude::*, stream::FuturesUnordered};
use instant::Instant;
use libp2p_core::upgrade::{NegotiationError, UpgradeError};
use libp2p_swarm::{
protocols_handler::{
@@ -44,7 +45,6 @@ use std::{
task::{Context, Poll},
time::Duration,
};
use wasm_timer::Instant;
/// A connection handler of a `RequestResponse` protocol.
#[doc(hidden)]