Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
USD fiat skip check against exchange API (#337)
Browse files Browse the repository at this point in the history
* Added fiat code check for USD to prevent querying the exchange API unnecessarily

* Moved usd check to info provider
  • Loading branch information
jpalvarezl authored Apr 6, 2021
1 parent b4895f1 commit 0393127
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/providers/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ impl DefaultInfoProvider<'_> {
}

pub fn exchange_usd_to(&self, currency_code: &str) -> ApiResult<f64> {
if &currency_code.to_lowercase() == "usd" {
return Ok(1.0);
}

let currency_code = currency_code.to_uppercase();
let exchange = self.fetch_exchange()?;
match exchange.rates {
Expand Down

0 comments on commit 0393127

Please sign in to comment.