mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-08 06:01:57 -07:00
global: snap
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user