mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-06 23:33:07 +00:00
configs: avoid SocketAddr parse unwrap
This commit is contained in:
parent
4f202295ba
commit
9b2cfeadfe
@ -3,6 +3,8 @@ use std::net::SocketAddr;
|
|||||||
use nomos_utils::net::get_available_tcp_port;
|
use nomos_utils::net::get_available_tcp_port;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const LOCALHOST: [u8; 4] = [127, 0, 0, 1];
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GeneralApiConfig {
|
pub struct GeneralApiConfig {
|
||||||
pub address: SocketAddr,
|
pub address: SocketAddr,
|
||||||
@ -23,8 +25,8 @@ pub fn create_api_configs(ids: &[[u8; 32]]) -> Result<Vec<GeneralApiConfig>, Api
|
|||||||
let testing_port =
|
let testing_port =
|
||||||
get_available_tcp_port().ok_or(ApiConfigError::PortAllocationFailed)?;
|
get_available_tcp_port().ok_or(ApiConfigError::PortAllocationFailed)?;
|
||||||
Ok(GeneralApiConfig {
|
Ok(GeneralApiConfig {
|
||||||
address: format!("127.0.0.1:{address_port}").parse().unwrap(),
|
address: SocketAddr::from((LOCALHOST, address_port)),
|
||||||
testing_http_address: format!("127.0.0.1:{testing_port}").parse().unwrap(),
|
testing_http_address: SocketAddr::from((LOCALHOST, testing_port)),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user