Skip to content

Commit

Permalink
core: services: address multi-arch builds
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Perchanov <[email protected]>
  • Loading branch information
demisrael committed Sep 24, 2024
1 parent 856e079 commit 118854a
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions core/src/runtime/services/kaspa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl KaspaService {
encoding,
resolver_urls,
} => {
let mut resolver_or_none = match url {
let resolver_or_none = match url {
Some(_) => None,
None => {
if resolver_urls.is_none() {
Expand All @@ -198,13 +198,7 @@ impl KaspaService {
}
};

let wrpc_url = get_wrpc_url().unwrap_or_else(|| "".to_string());
let url = if !wrpc_url.is_empty() {
resolver_or_none = None;
wrpc_url.clone()
} else {
url.clone().unwrap_or_else(|| "127.0.0.1".to_string())
};
let url = url.clone().unwrap_or_else(|| "127.0.0.1".to_string());
let url =
KaspaRpcClient::parse_url(url, *encoding, NetworkId::from(network).into())?;

Expand Down Expand Up @@ -608,14 +602,27 @@ impl KaspaService {
} else {
self.stop_all_services().await?;

#[cfg(not(target_arch = "wasm32"))]
let url = "".to_string();
#[cfg(target_arch = "wasm32")]
let url = get_wrpc_url().unwrap_or_else(|| "".to_string());
let network = match url.as_str() {
u if u.contains("testnet-10") => Network::Testnet10,
u if u.contains("testnet-11") => Network::Testnet11,
_ => Network::Mainnet,
_ => network,
};

self.handle_network_change(network).await?;

let rpc_config = if url.is_empty() {
rpc_config.clone()
} else {
RpcConfig::Wrpc {
url: url.into(),
encoding: WrpcEncoding::Borsh,
resolver_urls: None,
}
};
let rpc = Self::create_rpc_client(&rpc_config, network)
.expect("Kaspad Service - unable to create wRPC client");
self.start_all_services(Some(rpc), network).await?;
Expand Down

0 comments on commit 118854a

Please sign in to comment.