replace lazy_static! with once_cell::sync::Lazy

This commit is contained in:
hinto.janai 2023-11-05 09:43:40 -05:00 committed by Luke Parker
parent de41be6e26
commit bd3272a9f2
6 changed files with 14 additions and 17 deletions

4
Cargo.lock generated
View file

@ -8387,8 +8387,8 @@ dependencies = [
"flexible-transcript", "flexible-transcript",
"hex", "hex",
"jsonrpsee", "jsonrpsee",
"lazy_static",
"log", "log",
"once_cell",
"rand_core", "rand_core",
"reqwest", "reqwest",
"schnorr-signatures", "schnorr-signatures",
@ -8503,10 +8503,10 @@ dependencies = [
"futures", "futures",
"hex", "hex",
"k256", "k256",
"lazy_static",
"log", "log",
"modular-frost", "modular-frost",
"monero-serai", "monero-serai",
"once_cell",
"parity-scale-codec", "parity-scale-codec",
"rand_chacha", "rand_chacha",
"rand_core", "rand_core",

View file

@ -15,7 +15,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies] [dependencies]
# Macros # Macros
lazy_static = { version = "1", default-features = false } once_cell = { version = "1", default-features = false }
serde = { version = "1", default-features = false, features = ["std", "derive"] } serde = { version = "1", default-features = false, features = ["std", "derive"] }
# Encoders # Encoders

View file

@ -28,12 +28,11 @@ mod binaries {
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
mod clippy { mod clippy {
use super::*; use super::*;
lazy_static::lazy_static! { use once_cell::sync::Lazy;
pub(crate) static ref KEYS: Arc<RwLock<HashMap<Service, <Ristretto as Ciphersuite>::G>>> = pub(crate) static KEYS: Lazy<Arc<RwLock<HashMap<Service, <Ristretto as Ciphersuite>::G>>>> =
Arc::new(RwLock::new(HashMap::new())); Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub(crate) static ref QUEUES: Arc<RwLock<HashMap<(Service, Service), RwLock<Queue<Db>>>>> = pub(crate) static QUEUES: Lazy<Arc<RwLock<HashMap<(Service, Service), RwLock<Queue<Db>>>>>> =
Arc::new(RwLock::new(HashMap::new())); Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
}
} }
pub(crate) use self::clippy::*; pub(crate) use self::clippy::*;

View file

@ -16,7 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies] [dependencies]
# Macros # Macros
async-trait = { version = "0.1", default-features = false } async-trait = { version = "0.1", default-features = false }
lazy_static = { version = "1", default-features = false } once_cell = { version = "1", default-features = false }
zeroize = { version = "1", default-features = false, features = ["std"] } zeroize = { version = "1", default-features = false, features = ["std"] }
thiserror = { version = "1", default-features = false } thiserror = { version = "1", default-features = false }
serde = { version = "1", default-features = false, features = ["std", "derive"] } serde = { version = "1", default-features = false, features = ["std", "derive"] }

View file

@ -53,6 +53,8 @@ use crate::{
Payment, Payment,
}; };
use once_cell::sync::Lazy;
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub struct OutputId(pub [u8; 36]); pub struct OutputId(pub [u8; 36]);
impl Default for OutputId { impl Default for OutputId {
@ -259,10 +261,8 @@ impl BlockTrait<Bitcoin> for Block {
} }
const KEY_DST: &[u8] = b"Serai Bitcoin Output Offset"; const KEY_DST: &[u8] = b"Serai Bitcoin Output Offset";
lazy_static::lazy_static! { static BRANCH_OFFSET: Lazy<Scalar> = Lazy::new(|| Secp256k1::hash_to_F(KEY_DST, b"branch"));
static ref BRANCH_OFFSET: Scalar = Secp256k1::hash_to_F(KEY_DST, b"branch"); static CHANGE_OFFSET: Lazy<Scalar> = Lazy::new(|| Secp256k1::hash_to_F(KEY_DST, b"change"));
static ref CHANGE_OFFSET: Scalar = Secp256k1::hash_to_F(KEY_DST, b"change");
}
// Always construct the full scanner in order to ensure there's no collisions // Always construct the full scanner in order to ensure there's no collisions
fn scanner( fn scanner(

View file

@ -16,9 +16,7 @@ mod addresses;
pub(crate) use addresses::test_addresses; pub(crate) use addresses::test_addresses;
// Effective Once // Effective Once
lazy_static::lazy_static! { static INIT_LOGGER: once_cell::sync::Lazy<()> = once_cell::sync::Lazy::new(env_logger::init);
static ref INIT_LOGGER: () = env_logger::init();
}
#[macro_export] #[macro_export]
macro_rules! test_network { macro_rules! test_network {