mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-03-31 08:13:48 +00:00
Encapsulate external node source fields
This commit is contained in:
parent
0ff1ae1904
commit
74290327a3
@ -44,7 +44,7 @@ impl Application for LbcExtEnv {
|
||||
type FeedRuntime = <LbcEnv as Application>::FeedRuntime;
|
||||
|
||||
fn external_node_client(source: &ExternalNodeSource) -> Result<Self::NodeClient, DynError> {
|
||||
let base_url = Url::parse(&source.endpoint)?;
|
||||
let base_url = Url::parse(source.endpoint())?;
|
||||
Ok(NodeHttpClient::from_urls(base_url, None))
|
||||
}
|
||||
|
||||
|
||||
@ -71,11 +71,11 @@ impl<E: Application> ExternalProvider<E> for ApplicationExternalProvider {
|
||||
.map(|source| {
|
||||
E::external_node_client(source)
|
||||
.map(|client| ExternalNode {
|
||||
identity_hint: Some(source.label.clone()),
|
||||
identity_hint: Some(source.label().to_string()),
|
||||
client,
|
||||
})
|
||||
.map_err(|build_error| ExternalProviderError::Build {
|
||||
source_label: source.label.clone(),
|
||||
source_label: source.label().to_string(),
|
||||
source: build_error,
|
||||
})
|
||||
})
|
||||
|
||||
@ -49,8 +49,8 @@ impl AttachSource {
|
||||
/// inventory.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct ExternalNodeSource {
|
||||
pub label: String,
|
||||
pub endpoint: String,
|
||||
label: String,
|
||||
endpoint: String,
|
||||
}
|
||||
|
||||
impl ExternalNodeSource {
|
||||
@ -58,6 +58,16 @@ impl ExternalNodeSource {
|
||||
pub fn new(label: String, endpoint: String) -> Self {
|
||||
Self { label, endpoint }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn label(&self) -> &str {
|
||||
&self.label
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn endpoint(&self) -> &str {
|
||||
&self.endpoint
|
||||
}
|
||||
}
|
||||
|
||||
/// Planned readiness strategy for mixed managed/attached/external sources.
|
||||
|
||||
@ -35,8 +35,8 @@ pub fn build_external_client<E: LocalDeployerEnv>(
|
||||
}
|
||||
|
||||
fn resolve_api_socket(source: &ExternalNodeSource) -> Result<std::net::SocketAddr, DynError> {
|
||||
let source_label = source.label.clone();
|
||||
let endpoint = source.endpoint.trim();
|
||||
let source_label = source.label().to_string();
|
||||
let endpoint = source.endpoint().trim();
|
||||
if endpoint.is_empty() {
|
||||
return Err(ExternalClientBuildError::EmptyEndpoint {
|
||||
label: source_label,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user