use super::*;
#[derive(Boilerplate)]
pub(crate) struct BlocksHtml {
last: u32,
blocks: Vec<BlockHash>,
featured_blocks: BTreeMap<BlockHash, Vec<InscriptionId>>,
}
impl BlocksHtml {
pub(crate) fn new(
blocks: Vec<(u32, BlockHash)>,
featured_blocks: BTreeMap<BlockHash, Vec<InscriptionId>>,
) -> Self {
Self {
last: blocks
.get(0)
.map(|(height, _)| height)
.cloned()
.unwrap_or(0),
blocks: blocks.into_iter().map(|(_, hash)| hash).collect(),
featured_blocks,
}
}
}
impl PageContent for BlocksHtml {
fn title(&self) -> String {
"Blocks".to_string()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn html() {
let mut feature_blocks = BTreeMap::new();
feature_blocks.insert(
"2222222222222222222222222222222222222222222222222222222222222222"
.parse()
.unwrap(),
vec![inscription_id(1), inscription_id(2)],
);
assert_regex_match!(
&BlocksHtml::new(
vec![
(
1260002,