mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-05-05 09:23:07 +00:00
configs: remove ProviderId unwrap
This commit is contained in:
parent
9b2cfeadfe
commit
9f403bf235
@ -40,10 +40,16 @@ pub fn secret_key_to_peer_id(node_key: nomos_libp2p::ed25519::SecretKey) -> Peer
|
|||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn secret_key_to_provider_id(node_key: nomos_libp2p::ed25519::SecretKey) -> ProviderId {
|
pub fn secret_key_to_provider_id(node_key: nomos_libp2p::ed25519::SecretKey) -> ProviderId {
|
||||||
ProviderId::try_from(
|
let bytes = nomos_libp2p::ed25519::Keypair::from(node_key)
|
||||||
nomos_libp2p::ed25519::Keypair::from(node_key)
|
.public()
|
||||||
.public()
|
.to_bytes();
|
||||||
.to_bytes(),
|
match ProviderId::try_from(bytes) {
|
||||||
)
|
Ok(value) => value,
|
||||||
.unwrap()
|
Err(_) => unsafe {
|
||||||
|
// Safety: `bytes` is a 32-byte ed25519 public key, matching `ProviderId`'s
|
||||||
|
// expected width; failure would indicate a broken invariant in the
|
||||||
|
// dependency.
|
||||||
|
std::hint::unreachable_unchecked()
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user