Replace lazy_static! with LazyLock (#6189)

* Replace `lazy_static` with `LazyLock`.

* Merge branch 'unstable' into remove-lazy-static

# Conflicts:
#	beacon_node/lighthouse_network/src/peer_manager/mod.rs

* Lint fixes.

* Merge branch 'unstable' into remove-lazy-static

# Conflicts:
#	beacon_node/beacon_chain/src/metrics.rs

* Moar lint fixes.

* Update rust version to 1.80.0.

* Merge branch 'unstable' into remove-lazy-static
This commit is contained in:
Jimmy Chen
2024-07-29 21:42:31 +10:00
committed by GitHub
parent 00038dae81
commit 96b00ef66c
85 changed files with 3512 additions and 2370 deletions

View File

@@ -1,7 +1,7 @@
use lazy_static::lazy_static;
use lru_cache::LRUTimeCache;
use parking_lot::Mutex;
use std::net::{SocketAddr, TcpListener, UdpSocket};
use std::sync::LazyLock;
use std::time::Duration;
#[derive(Copy, Clone)]
@@ -18,10 +18,8 @@ pub enum IpVersion {
pub const CACHED_PORTS_TTL: Duration = Duration::from_secs(300);
lazy_static! {
static ref FOUND_PORTS_CACHE: Mutex<LRUTimeCache<u16>> =
Mutex::new(LRUTimeCache::new(CACHED_PORTS_TTL));
}
static FOUND_PORTS_CACHE: LazyLock<Mutex<LRUTimeCache<u16>>> =
LazyLock::new(|| Mutex::new(LRUTimeCache::new(CACHED_PORTS_TTL)));
/// A convenience wrapper over [`zero_port`].
pub fn unused_tcp4_port() -> Result<u16, String> {