use std::borrow::Cow;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{Pool, PoolSlug};
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
pub struct PoolStats {
#[serde(rename = "poolId")]
pub pool_id: u8,
pub name: Cow<'static, str>,
pub link: Cow<'static, str>,
#[serde(rename = "blockCount")]
pub block_count: u64,
pub rank: u32,
#[serde(rename = "emptyBlocks")]
pub empty_blocks: u64,
pub slug: PoolSlug,
pub share: f64,
#[serde(rename = "poolUniqueId")]
pub pool_unique_id: u8,
}
impl PoolStats {
pub fn new(pool: &'static Pool, block_count: u64, rank: u32, share: f64) -> Self {
Self {
pool_id: pool.mempool_id(),
name: Cow::Borrowed(pool.name),
link: Cow::Borrowed(pool.link),
block_count,
rank,
empty_blocks: 0,
slug: pool.slug(),
share,
pool_unique_id: pool.mempool_unique_id(),
}
}
}