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()
|
||||
|
||||
@@ -211,6 +211,7 @@ pub async fn get_market(dashboard: Arc<Mutex<Dashboard>>) -> Result<(), anyhow::
|
||||
let inflation = (31536000.0 / (supply as f64)) * 100.0;
|
||||
|
||||
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
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
<br>
|
||||
<a href="https://grincoin.org/rpc/block/latest">https://grincoin.org/rpc/block/latest</a><br>
|
||||
<a href="https://grincoin.org/rpc/market/supply">https://grincoin.org/rpc/market/supply</a><br>
|
||||
<a href="https://grincoin.org/rpc/market/supply_raw">https://grincoin.org/rpc/market/supply_raw</a><br>
|
||||
<a href="https://grincoin.org/rpc/network/hashrate">https://grincoin.org/rpc/network/hashrate</a><br>
|
||||
<a href="https://grincoin.org/rpc/network/difficulty">https://grincoin.org/rpc/network/difficulty</a><br><br>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user