Skip to content

Commit

Permalink
Merge pull request #170 from zancas/remove_deprecated_price_fetch
Browse files Browse the repository at this point in the history
Remove deprecated price fetch
  • Loading branch information
AloeareV authored Nov 8, 2022
2 parents b018733 + ae7e3a4 commit d1182ed
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 48 deletions.
25 changes: 0 additions & 25 deletions lib/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,30 +373,6 @@ impl Command for InfoCommand {
}
}

struct ZecPriceCommand {}
impl Command for ZecPriceCommand {
fn help(&self) -> String {
let mut h = vec![];
h.push("Use UpdateCurrentPriceCommand instead.");
h.push("Backwards compatible price fetch");
h.push("Get the latest ZEC price from Gemini exchange's API.");
h.push("Currently using USD.");
h.push("Usage:");
h.push("zecprice");
h.push("");

h.join("\n")
}

fn short_help(&self) -> String {
"Get the latest ZEC price in the wallet's currency (USD)".to_string()
}

fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String {
RT.block_on(async move { lightclient.do_zec_price().await })
}
}

struct UpdateCurrentPriceCommand {}
impl Command for UpdateCurrentPriceCommand {
fn help(&self) -> String {
Expand Down Expand Up @@ -1313,7 +1289,6 @@ pub fn get_commands() -> Box<HashMap<String, Box<dyn Command>>> {
map.insert("import".to_string(), Box::new(ImportCommand {}));
map.insert("export".to_string(), Box::new(ExportCommand {}));
map.insert("info".to_string(), Box::new(InfoCommand {}));
map.insert("zecprice".to_string(), Box::new(ZecPriceCommand {}));
map.insert(
"updatecurrentprice".to_string(),
Box::new(UpdateCurrentPriceCommand {}),
Expand Down
23 changes: 0 additions & 23 deletions lib/src/lightclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,29 +573,6 @@ impl LightClient {
self.config.get_server_uri()
}

pub async fn do_zec_price(&self) -> String {
let mut price = self.wallet.price.read().await.clone();

// If there is no price, try to fetch it first.
if price.zec_price.is_none() {
self.update_current_price().await;
price = self.wallet.price.read().await.clone();
}

match price.zec_price {
None => return "Error: No price".to_string(),
Some((timestamp, p)) => {
let o = object! {
"zec_price" => p,
"fetched_at" => timestamp,
"currency" => price.currency
};

o.pretty(2)
}
}
}

pub async fn do_info(&self) -> String {
match GrpcConnector::get_info(self.get_server_uri()).await {
Ok(i) => {
Expand Down

0 comments on commit d1182ed

Please sign in to comment.