added raw supply api endpoint

This commit is contained in:
aglkm
2025-10-29 17:13:41 +03:00
parent a6cd6a5236
commit e2b96cc51f
4 changed files with 15 additions and 3 deletions
+2
View File
@@ -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
View File
@@ -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
View File
@@ -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);
+1
View File
@@ -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>