Files
nym/explorer-api/src/mix_nodes/utils.rs
T
Mark Sinclair ccf8063a52 Explorer API: add new HTTP resource to decorate mix nodes with geoip locations (#734)
* explorer-api: decorate mix nodes with locations from the geoip service and keep mix node cache in a hash map instead of a vec

* explorer-api: add `lat` and `lng` for map views

* explorer-api: remove function and simplify code

* explorer-api: review feedback

* network-explorer: format
2021-08-11 17:24:34 +01:00

16 lines
502 B
Rust

use crate::mix_nodes::GeoLocation;
use isocountry::CountryCode;
pub(crate) fn map_2_letter_to_3_letter_country_code(geo: &GeoLocation) -> String {
match CountryCode::for_alpha2(&geo.country_code) {
Ok(three_letter_country_code) => three_letter_country_code.alpha3().to_string(),
Err(_e) => {
warn!(
"❌ Oh no! map_2_letter_to_3_letter_country_code failed for '{:#?}'",
geo
);
"???".to_string()
}
}
}