Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions crates/precompile/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ static CRYPTO: OnceLock<Box<dyn Crypto>> = OnceLock::new();

/// Install a custom crypto provider globally.
pub fn install_crypto<C: Crypto + 'static>(crypto: C) -> bool {
if CRYPTO.get().is_some() {
return false;
}

CRYPTO.get_or_init(|| Box::new(crypto));
true
CRYPTO.set(Box::new(crypto)).is_ok()
}

/// Get the installed crypto provider, or the default if none is installed.
Expand Down
6 changes: 6 additions & 0 deletions crates/primitives/src/once_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ mod no_std_impl {
pub fn get(&self) -> Option<&T> {
self.inner.get()
}

/// Sets the contents of the OnceLock.
#[inline]
pub fn set(&self, value: T) -> Result<(), T> {
self.inner.set(Box::new(value)).map_err(|e| *e)
}
}
}

Expand Down
Loading