diff --git a/crates/brk_query/src/impl/block/info.rs b/crates/brk_query/src/impl/block/info.rs index a9c461d0c..36ba89773 100644 --- a/crates/brk_query/src/impl/block/info.rs +++ b/crates/brk_query/src/impl/block/info.rs @@ -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, diff --git a/crates/brk_query/src/impl/mining/pools.rs b/crates/brk_query/src/impl/mining/pools.rs index 2c85e1e0a..7a1255944 100644 --- a/crates/brk_query/src/impl/mining/pools.rs +++ b/crates/brk_query/src/impl/mining/pools.rs @@ -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)), }) } diff --git a/crates/brk_types/src/pool.rs b/crates/brk_types/src/pool.rs index 7d96b3ca4..ee4185edb 100644 --- a/crates/brk_types/src/pool.rs +++ b/crates/brk_types/src/pool.rs @@ -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 + } } diff --git a/crates/brk_types/src/pool_detail.rs b/crates/brk_types/src/pool_detail.rs index f3870a321..df873c938 100644 --- a/crates/brk_types/src/pool_detail.rs +++ b/crates/brk_types/src/pool_detail.rs @@ -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, + + /// Total reward earned by this pool (sats, all time; None for minor pools) + #[serde(rename = "totalReward")] + pub total_reward: Option, } /// 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(), } } } diff --git a/crates/brk_types/src/pool_info.rs b/crates/brk_types/src/pool_info.rs index 0523be85e..d324feec6 100644 --- a/crates/brk_types/src/pool_info.rs +++ b/crates/brk_types/src/pool_info.rs @@ -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(), } } } diff --git a/crates/brk_types/src/pool_stats.rs b/crates/brk_types/src/pool_stats.rs index 98a5ba65f..c6404310f 100644 --- a/crates/brk_types/src/pool_stats.rs +++ b/crates/brk_types/src/pool_stats.rs @@ -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(), } } } diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 9c104e3f4..3edaadf79 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -752,6 +752,7 @@ Matches mempool.space/bitcoin-cli behavior. * @property {PoolBlockShares} blockShare - Pool's share of total blocks for different time periods * @property {number} estimatedHashrate - Estimated hashrate based on blocks mined * @property {?number=} reportedHashrate - Self-reported hashrate (if available) + * @property {(Sats|null)=} totalReward - Total reward earned by this pool (sats, all time; None for minor pools) */ /** * Pool information for detail view diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index a470a5940..d95bab88b 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -1111,12 +1111,14 @@ class PoolDetail(TypedDict): blockShare: Pool's share of total blocks for different time periods estimatedHashrate: Estimated hashrate based on blocks mined reportedHashrate: Self-reported hashrate (if available) + totalReward: Total reward earned by this pool (sats, all time; None for minor pools) """ pool: PoolDetailInfo blockCount: PoolBlockCounts blockShare: PoolBlockShares estimatedHashrate: int reportedHashrate: Optional[int] + totalReward: Union[Sats, None] class PoolHashrateEntry(TypedDict): """