SHOWING: First 60
▣#70,547,309text▣#70,546,656textsenadormajor.btc#54,553,043textuse super::*;
fn target_as_block_hash(target: bitcoin::Target) -> BlockHash {
BlockHash::from_raw_hash(Hash::from_byte_array(target.to_le_bytes()))
}
#[derive(Boilerplate)]
pub(crate) struct BlockHtml {
hash: BlockHash,
target: BlockHash,
best_height: Height,
block: Block,
height: Height,
inscription_count: usize,
featured_inscriptions: Vec<InscriptionId>,
}
impl BlockHtml {
pub(crate) fn new(
block: Block,
height: Height,
best_height: Height,
inscription_count: usize,
featured_inscriptions: Vec<InscriptionId>,
) -> Self {
Self {
hash: block.header.block_hash(),
target: target_as_block_hash(block.header.target()),
block,
height,
best_height,
inscription_count,
featured_inscriptions,
}
}
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct BlockJson {
pub hash: BlockHash,
pub target: BlockHash,
pub best_height: u32,
pub height: u32,
pub inscriptions: Vec<InscriptionId>,
}
impl BlockJson {
pub(crate) fn new(#45,022,209textpub(crate) use {
super::*,
bitcoin::{
blockdata::{opcodes, script, script::PushBytesBuf},
ScriptBuf, Witness,
},
pretty_assertions::assert_eq as pretty_assert_eq,
std::iter,
test_bitcoincore_rpc::TransactionTemplate,
unindent::Unindent,
};
macro_rules! assert_regex_match {
($value:expr, $pattern:expr $(,)?) => {
let regex = Regex::new(&format!("^(?s){}$", $pattern)).unwrap();
let string = $value.to_string();
if !regex.is_match(string.as_ref()) {
panic!(
"Regex:\n\n{}\n\n…did not match string:\n\n{}",
regex, string
);
}
};
}
macro_rules! assert_matches {
($expression:expr, $( $pattern:pat_param )|+ $( if $guard:expr )? $(,)?) => {
match $expression {
$( $pattern )|+ $( if $guard )? => {}
left => panic!(
"assertion failed: (left ~= right)\n left: `{:?}`\n right: `{}`",
left,
stringify!($($pattern)|+ $(if $guard)?)
),
}
}
}
pub(crate) fn blockhash(n: u64) -> BlockHash {
let hex = format!("{n:x}");#45,021,660text685802.bitmap#13,926,971text138125.bitmap#13,044,112text