added raw supply api endpoint
This commit is contained in:
@@ -27,6 +27,7 @@ pub struct Dashboard {
|
||||
pub outbound: u16,
|
||||
// price & market
|
||||
pub supply: String,
|
||||
pub supply_raw: String,
|
||||
pub soft_supply: String,
|
||||
pub inflation: String,
|
||||
pub price_usd: String,
|
||||
@@ -65,6 +66,7 @@ impl Dashboard {
|
||||
inbound: 0,
|
||||
outbound: 0,
|
||||
supply: String::new(),
|
||||
supply_raw: String::new(),
|
||||
soft_supply: String::new(),
|
||||
inflation: String::new(),
|
||||
price_usd: String::new(),
|
||||
|
||||
+9
-1
@@ -487,6 +487,14 @@ fn market_supply(dashboard: &State<Arc<Mutex<Dashboard>>>) -> String {
|
||||
}
|
||||
|
||||
|
||||
#[get("/rpc/market/supply_raw")]
|
||||
fn supply_raw(dashboard: &State<Arc<Mutex<Dashboard>>>) -> String {
|
||||
let data = dashboard.lock().unwrap();
|
||||
|
||||
data.supply_raw.clone()
|
||||
}
|
||||
|
||||
|
||||
#[get("/rpc/market/soft_supply")]
|
||||
fn soft_supply(dashboard: &State<Arc<Mutex<Dashboard>>>) -> String {
|
||||
let data = dashboard.lock().unwrap();
|
||||
@@ -962,7 +970,7 @@ async fn main() {
|
||||
soft_supply, production_cost, reward_ratio, breakeven_cost,
|
||||
last_block_age, block_list_by_height, block_list_index, search, kernel,
|
||||
output, api_owner, api_foreign, stats, unspent_outputs, kernels,
|
||||
emission, api_overview, donate])
|
||||
emission, api_overview, donate, supply_raw])
|
||||
.mount("/static", FileServer::from("static"))
|
||||
.attach(Template::custom(|engines| {engines.tera.register_filter("separate_with_commas", separate_with_commas)}))
|
||||
.launch()
|
||||
|
||||
+3
-2
@@ -210,8 +210,9 @@ pub async fn get_market(dashboard: Arc<Mutex<Dashboard>>) -> Result<(), anyhow::
|
||||
// 31536000 seconds in a year
|
||||
let inflation = (31536000.0 / (supply as f64)) * 100.0;
|
||||
|
||||
data.inflation = format!("{:.2}", inflation);
|
||||
data.supply = supply.to_formatted_string(&Locale::en);
|
||||
data.inflation = format!("{:.2}", inflation);
|
||||
data.supply_raw = supply.to_string();
|
||||
data.supply = supply.to_formatted_string(&Locale::en);
|
||||
|
||||
// https://john-tromp.medium.com/a-case-for-using-soft-total-supply-1169a188d153
|
||||
data.soft_supply = format!("{:.2}", supply.to_string().parse::<f64>().unwrap() / 3150000000.0 * 100.0);
|
||||
|
||||
Reference in New Issue
Block a user