mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-29 10:41:21 +00:00
*: Remove lazy_static in favor of once_cell (#3110)
This commit is contained in:
parent
8b378d56d3
commit
7daa0c1145
@ -86,7 +86,6 @@ futures = "0.3.1"
|
|||||||
futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature
|
futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature
|
||||||
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
|
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
|
||||||
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
|
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
|
||||||
lazy_static = "1.2"
|
|
||||||
|
|
||||||
libp2p-autonat = { version = "0.9.0", path = "protocols/autonat", optional = true }
|
libp2p-autonat = { version = "0.9.0", path = "protocols/autonat", optional = true }
|
||||||
libp2p-core = { version = "0.38.0", path = "core" }
|
libp2p-core = { version = "0.38.0", path = "core" }
|
||||||
|
@ -19,7 +19,6 @@ fnv = "1.0"
|
|||||||
futures = { version = "0.3.1", features = ["executor", "thread-pool"] }
|
futures = { version = "0.3.1", features = ["executor", "thread-pool"] }
|
||||||
futures-timer = "3"
|
futures-timer = "3"
|
||||||
instant = "0.1.11"
|
instant = "0.1.11"
|
||||||
lazy_static = "1.2"
|
|
||||||
libsecp256k1 = { version = "0.7.0", optional = true }
|
libsecp256k1 = { version = "0.7.0", optional = true }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
multiaddr = { version = "0.16.0" }
|
multiaddr = { version = "0.16.0" }
|
||||||
@ -29,6 +28,7 @@ p256 = { version = "0.11.1", default-features = false, features = ["ecdsa"], opt
|
|||||||
parking_lot = "0.12.0"
|
parking_lot = "0.12.0"
|
||||||
pin-project = "1.0.0"
|
pin-project = "1.0.0"
|
||||||
prost = "0.11"
|
prost = "0.11"
|
||||||
|
once_cell = "1.16.0"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rw-stream-sink = { version = "0.3.0", path = "../misc/rw-stream-sink" }
|
rw-stream-sink = { version = "0.3.0", path = "../misc/rw-stream-sink" }
|
||||||
sha2 = "0.10.0"
|
sha2 = "0.10.0"
|
||||||
|
@ -27,8 +27,8 @@ use futures::{
|
|||||||
task::Context,
|
task::Context,
|
||||||
task::Poll,
|
task::Poll,
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use multiaddr::{Multiaddr, Protocol};
|
use multiaddr::{Multiaddr, Protocol};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rw_stream_sink::RwStreamSink;
|
use rw_stream_sink::RwStreamSink;
|
||||||
use std::{
|
use std::{
|
||||||
@ -38,9 +38,7 @@ use std::{
|
|||||||
pin::Pin,
|
pin::Pin,
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
static HUB: Lazy<Hub> = Lazy::new(|| Hub(Mutex::new(FnvHashMap::default())));
|
||||||
static ref HUB: Hub = Hub(Mutex::new(FnvHashMap::default()));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Hub(Mutex<FnvHashMap<NonZeroU64, ChannelSender>>);
|
struct Hub(Mutex<FnvHashMap<NonZeroU64, ChannelSender>>);
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ repository = "https://github.com/libp2p/rust-libp2p"
|
|||||||
bytes = "1"
|
bytes = "1"
|
||||||
curve25519-dalek = "3.0.0"
|
curve25519-dalek = "3.0.0"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
lazy_static = "1.2"
|
|
||||||
libp2p-core = { version = "0.38.0", path = "../../core" }
|
libp2p-core = { version = "0.38.0", path = "../../core" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
once_cell = "1.16.0"
|
||||||
prost = "0.11"
|
prost = "0.11"
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
sha2 = "0.10.0"
|
sha2 = "0.10.0"
|
||||||
|
@ -309,6 +309,7 @@ impl snow::types::Random for Rng {}
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::X25519;
|
use crate::X25519;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn handshake_hashes_disagree_if_prologue_differs() {
|
fn handshake_hashes_disagree_if_prologue_differs() {
|
||||||
@ -337,7 +338,5 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hack to work around borrow-checker.
|
// Hack to work around borrow-checker.
|
||||||
lazy_static::lazy_static! {
|
static TEST_KEY: Lazy<Keypair<X25519>> = Lazy::new(Keypair::<X25519>::new);
|
||||||
static ref TEST_KEY: Keypair<X25519> = Keypair::<X25519>::new();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
use crate::{NoiseConfig, NoiseError, Protocol, ProtocolParams};
|
use crate::{NoiseConfig, NoiseError, Protocol, ProtocolParams};
|
||||||
use curve25519_dalek::edwards::CompressedEdwardsY;
|
use curve25519_dalek::edwards::CompressedEdwardsY;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use libp2p_core::UpgradeInfo;
|
use libp2p_core::UpgradeInfo;
|
||||||
use libp2p_core::{identity, identity::ed25519};
|
use libp2p_core::{identity, identity::ed25519};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use sha2::{Digest, Sha512};
|
use sha2::{Digest, Sha512};
|
||||||
use x25519_dalek::{x25519, X25519_BASEPOINT_BYTES};
|
use x25519_dalek::{x25519, X25519_BASEPOINT_BYTES};
|
||||||
@ -35,20 +35,24 @@ use zeroize::Zeroize;
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
lazy_static! {
|
static PARAMS_IK: Lazy<ProtocolParams> = Lazy::new(|| {
|
||||||
static ref PARAMS_IK: ProtocolParams = "Noise_IK_25519_ChaChaPoly_SHA256"
|
"Noise_IK_25519_ChaChaPoly_SHA256"
|
||||||
.parse()
|
.parse()
|
||||||
.map(ProtocolParams)
|
.map(ProtocolParams)
|
||||||
.expect("Invalid protocol name");
|
.expect("Invalid protocol name")
|
||||||
static ref PARAMS_IX: ProtocolParams = "Noise_IX_25519_ChaChaPoly_SHA256"
|
});
|
||||||
|
static PARAMS_IX: Lazy<ProtocolParams> = Lazy::new(|| {
|
||||||
|
"Noise_IX_25519_ChaChaPoly_SHA256"
|
||||||
.parse()
|
.parse()
|
||||||
.map(ProtocolParams)
|
.map(ProtocolParams)
|
||||||
.expect("Invalid protocol name");
|
.expect("Invalid protocol name")
|
||||||
static ref PARAMS_XX: ProtocolParams = "Noise_XX_25519_ChaChaPoly_SHA256"
|
});
|
||||||
|
static PARAMS_XX: Lazy<ProtocolParams> = Lazy::new(|| {
|
||||||
|
"Noise_XX_25519_ChaChaPoly_SHA256"
|
||||||
.parse()
|
.parse()
|
||||||
.map(ProtocolParams)
|
.map(ProtocolParams)
|
||||||
.expect("Invalid protocol name");
|
.expect("Invalid protocol name")
|
||||||
}
|
});
|
||||||
|
|
||||||
/// A X25519 key.
|
/// A X25519 key.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user