allow sp routing score to be undefined
This commit is contained in:
@@ -9,8 +9,8 @@ use rocket_okapi::settings::OpenApiSettings;
|
||||
const SERVICE_PROVIDER_WELLKNOWN_URL: &str =
|
||||
"https://nymtech.net/.wellknown/connect/service-providers.json";
|
||||
|
||||
const HARBOUR_MASTER_URL: &str = "https://harbourmaster.nymtech.net/v1/services/?size=100";
|
||||
const HM_SINCE_MIN: u32 = 1000000;
|
||||
const HARBOUR_MASTER_URL: &str = "https://harbourmaster.nymtech.net/v1/services";
|
||||
const HM_SINCE_MIN: u32 = 60;
|
||||
const HM_SIZE: u8 = 100;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -64,14 +64,29 @@ pub async fn get_services() -> Result<Vec<DirectorySpDetailed>, GetSpError> {
|
||||
.items
|
||||
.iter()
|
||||
.find(|item| item.service_provider_client_id == dir_sp.address);
|
||||
acc.push(DirectorySpDetailed {
|
||||
id: dir_sp.id.clone(),
|
||||
description: dir_sp.description.clone(),
|
||||
address: dir_sp.address.clone(),
|
||||
gateway: dir_sp.gateway.clone(),
|
||||
routing_score: directory_sp.map(|sp| sp.routing_score),
|
||||
service_type: "something".into(),
|
||||
});
|
||||
if let Some(sp) = directory_sp {
|
||||
acc.push(DirectorySpDetailed {
|
||||
id: sp.service_provider_client_id.clone(),
|
||||
description: dir_sp.description.clone(),
|
||||
address: dir_sp.address.clone(),
|
||||
gateway: dir_sp.gateway.clone(),
|
||||
routing_score: Some(sp.routing_score),
|
||||
service_type: "Network requester".into(),
|
||||
});
|
||||
} else {
|
||||
acc.push(DirectorySpDetailed {
|
||||
id: dir_sp.address.clone(),
|
||||
description: dir_sp.description.clone(),
|
||||
address: dir_sp.address.clone(),
|
||||
gateway: dir_sp.gateway.clone(),
|
||||
routing_score: None,
|
||||
service_type: "Network requester".into(),
|
||||
});
|
||||
log::warn!(
|
||||
"service provider info not found in Harbour Master data {}",
|
||||
dir_sp.address
|
||||
);
|
||||
}
|
||||
acc
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user