mirror of
https://github.com/transatoshi-mw/grin-explorer.git
synced 2025-10-21 13:33:41 +00:00
removed unwrap and code cleanup
This commit is contained in:
@@ -24,7 +24,6 @@ pub struct Dashboard {
|
|||||||
pub cap_btc: String,
|
pub cap_btc: String,
|
||||||
// blockchain
|
// blockchain
|
||||||
pub disk_usage: String,
|
pub disk_usage: String,
|
||||||
pub age: String,
|
|
||||||
// hashrate
|
// hashrate
|
||||||
pub hashrate: String,
|
pub hashrate: String,
|
||||||
pub difficulty: String,
|
pub difficulty: String,
|
||||||
@@ -56,7 +55,6 @@ impl Dashboard {
|
|||||||
cap_usd: String::new(),
|
cap_usd: String::new(),
|
||||||
cap_btc: String::new(),
|
cap_btc: String::new(),
|
||||||
disk_usage: String::new(),
|
disk_usage: String::new(),
|
||||||
age: String::new(),
|
|
||||||
hashrate: String::new(),
|
hashrate: String::new(),
|
||||||
difficulty: String::new(),
|
difficulty: String::new(),
|
||||||
production_cost: String::new(),
|
production_cost: String::new(),
|
||||||
|
10
src/main.rs
10
src/main.rs
@@ -1,4 +1,5 @@
|
|||||||
#[macro_use] extern crate rocket;
|
#[macro_use] extern crate rocket;
|
||||||
|
use either::Either;
|
||||||
use rocket_dyn_templates::{Template, context};
|
use rocket_dyn_templates::{Template, context};
|
||||||
use rocket::fs::FileServer;
|
use rocket::fs::FileServer;
|
||||||
use rocket::{State, tokio};
|
use rocket::{State, tokio};
|
||||||
@@ -6,18 +7,17 @@ use rocket::response::Redirect;
|
|||||||
use rocket::serde::json::json;
|
use rocket::serde::json::json;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use either::Either;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
mod worker;
|
|
||||||
mod requests;
|
|
||||||
mod data;
|
mod data;
|
||||||
|
mod requests;
|
||||||
|
mod worker;
|
||||||
|
|
||||||
use crate::data::Dashboard;
|
|
||||||
use crate::data::Block;
|
use crate::data::Block;
|
||||||
use crate::data::Transactions;
|
use crate::data::Dashboard;
|
||||||
use crate::data::Kernel;
|
use crate::data::Kernel;
|
||||||
use crate::data::Output;
|
use crate::data::Output;
|
||||||
|
use crate::data::Transactions;
|
||||||
use crate::requests::CONFIG;
|
use crate::requests::CONFIG;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -187,7 +187,7 @@ pub async fn get_market(dashboard: Arc<Mutex<Dashboard>>) -> Result<(), anyhow::
|
|||||||
if CONFIG.coingecko_api == "enabled" && val != Value::Null {
|
if CONFIG.coingecko_api == "enabled" && val != Value::Null {
|
||||||
// Check if CoingGecko API returned error
|
// Check if CoingGecko API returned error
|
||||||
if let Some(status) = val.get("status") {
|
if let Some(status) = val.get("status") {
|
||||||
warn!("{}", status["error_message"].as_str().unwrap().to_string());
|
warn!("{}", status["error_message"].to_string());
|
||||||
} else {
|
} else {
|
||||||
data.price_usd = format!("{:.3}", val["grin"]["usd"].to_string().parse::<f64>().unwrap());
|
data.price_usd = format!("{:.3}", val["grin"]["usd"].to_string().parse::<f64>().unwrap());
|
||||||
data.price_btc = format!("{:.8}", val["grin"]["btc"].to_string().parse::<f64>().unwrap());
|
data.price_btc = format!("{:.8}", val["grin"]["btc"].to_string().parse::<f64>().unwrap());
|
||||||
|
Reference in New Issue
Block a user