global: snap

This commit is contained in:
nym21
2026-04-04 20:13:03 +02:00
parent 62f51761ee
commit 7fac0bc613
8 changed files with 26 additions and 10 deletions

View File

@@ -341,7 +341,7 @@ impl Query {
],
reward: subsidy + total_fees,
pool: BlockPool {
id: pool.unique_id(),
id: pool.mempool_unique_id(),
name: pool.name.to_string(),
slug: pool_slug,
miner_names,

View File

@@ -275,6 +275,11 @@ impl Query {
(share_24h * network_hr as f64) as u128
},
reported_hashrate: None,
total_reward: computer
.pools
.major
.get(&slug)
.and_then(|v| v.rewards.cumulative.sats.height.collect_one(current_height)),
})
}

View File

@@ -35,8 +35,13 @@ impl Pool {
self.slug
}
/// Get the pool's unique numeric ID
pub fn unique_id(&self) -> u8 {
/// Pool ID matching mempool.space's `unique_id` field (0-indexed, raw pools-v2.json value)
pub fn mempool_unique_id(&self) -> u8 {
self.slug.into()
}
/// Pool ID matching mempool.space's `id` field (1-indexed)
pub fn mempool_id(&self) -> u8 {
self.mempool_unique_id() + 1
}
}

View File

@@ -3,7 +3,7 @@ use std::borrow::Cow;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{Pool, PoolSlug};
use crate::{Pool, PoolSlug, Sats};
/// Detailed pool information with statistics across time periods
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
@@ -26,6 +26,10 @@ pub struct PoolDetail {
/// Self-reported hashrate (if available)
#[serde(rename = "reportedHashrate")]
pub reported_hashrate: Option<u128>,
/// Total reward earned by this pool (sats, all time; None for minor pools)
#[serde(rename = "totalReward")]
pub total_reward: Option<Sats>,
}
/// Pool information for detail view
@@ -56,13 +60,13 @@ pub struct PoolDetailInfo {
impl From<&'static Pool> for PoolDetailInfo {
fn from(pool: &'static Pool) -> Self {
Self {
id: pool.unique_id(),
id: pool.mempool_id(),
name: Cow::Borrowed(pool.name),
link: Cow::Borrowed(pool.link),
addresses: pool.addrs.iter().map(|&s| Cow::Borrowed(s)).collect(),
regexes: pool.tags.iter().map(|&s| Cow::Borrowed(s)).collect(),
slug: pool.slug(),
unique_id: pool.unique_id(),
unique_id: pool.mempool_unique_id(),
}
}
}

View File

@@ -23,7 +23,7 @@ impl From<&'static Pool> for PoolInfo {
Self {
name: Cow::Borrowed(pool.name),
slug: pool.slug(),
unique_id: pool.unique_id(),
unique_id: pool.mempool_unique_id(),
}
}
}

View File

@@ -43,9 +43,8 @@ pub struct PoolStats {
impl PoolStats {
/// Create a new PoolStats from a Pool reference
pub fn new(pool: &'static Pool, block_count: u64, rank: u32, share: f64) -> Self {
let id = pool.unique_id();
Self {
pool_id: id,
pool_id: pool.mempool_id(),
name: Cow::Borrowed(pool.name),
link: Cow::Borrowed(pool.link),
block_count,
@@ -53,7 +52,7 @@ impl PoolStats {
empty_blocks: 0,
slug: pool.slug(),
share,
pool_unique_id: id,
pool_unique_id: pool.mempool_unique_id(),
}
}
}