transfer100.pizza#71,328,107brc-20Inscription #35153073#35,153,073htmlInscription #35060647#35,060,647png@newjeans#18,600,207text@wonyoung#18,600,206text@minji#18,600,205text@karina#18,600,204textInscription #14342254#14,342,254htmlInscription #13510585#13,510,585pngInscription #12592215#12,592,215jpguse super::*; #[derive(Display)] pub(crate) struct ClockSvg { height: Height, hour: f64, minute: f64, second: f64, } impl ClockSvg { pub(crate) fn new(height: Height) -> Self { let min = height.min(Epoch::FIRST_POST_SUBSIDY.starting_height()); Self { height, hour: (min.n() % Epoch::FIRST_POST_SUBSIDY.starting_height().n()) as f64 / Epoch::FIRST_POST_SUBSIDY.starting_height().n() as f64 * 360.0, minute: (min.n() % Epoch::BLOCKS) as f64 / Epoch::BLOCKS as f64 * 360.0, second: height.period_offset() as f64 / PERIOD_BLOCKS as f64 * 360.0, } } } #[cfg(test)] mod tests { use {super::*, pretty_assertions::assert_eq}; #[test] fn second() { assert_eq!(ClockSvg::new(Height(0)).second, 0.0); assert_eq!(ClockSvg::new(Height(504)).second, 90.0); assert_eq!(ClockSvg::new(Height(1008)).second, 180.0); assert_eq!(ClockSvg::new(Height(1512)).second, 270.0); assert_eq!(ClockSvg::new(Height(2016)).second, 0.0); assert_eq!(ClockSvg::new(Height(6930000)).second, 180.0); assert_eq!(ClockSvg::new(Height(6930504)).second, 270.0); } #[test] fn minute() { assert_eq!(ClockSvg::new(Height(0)).minute, 0.0); assert_eq!(ClockSvg::new(Height(52500)).minute, 90.0); assert_eq!(ClockSvg::new(Height(105000)).minute, 180.0); assert_eq!(ClockSvg::new(Height(157500)).minute, 270.0); assert_eq!(ClockSvg::new(Height(210000)).minute, 0.0); assert_eq!(ClockSvg::new(Height(6930000)).minute, 0.0); assert_eq!(ClockSvg::new(Height(6930001)).minute, 0.0); } #[test] fn hour() { assert_eq!(ClockSvg::new(Height(0)).hour, 0.0); assert_eq!(ClockSvg::new(Height(1732500)).hour, 90.0); assert_eq!(ClockSvg::new(Height(3465000)).hour, 180.0); assert_eq!(ClockSvg::new(Height(5197500)).hour, 270.0); assert_eq!(ClockSvg::new(Height(6930000)).hour, 0.0); assert_eq!(ClockSvg::new(Height(6930001)).hour, 0.0); } #[test] fn final_subsidy_height() { assert_eq!( ClockSvg::new(Height(6929999)).second, 1007.0 / 2016.0 * 360.0 ); assert_eq!( ClockSvg::new(Height(6929999)).minute, 209_999.0 / 210_000.0 * 360.0 ); assert_eq!( ClockSvg::new(Height(6929999)).hour, 6929999.0 / 6930000.0 * 360.0 ); } #[test] fn first_post_subsidy_height() { assert_eq!(ClockSvg::new(Height(6930000)).second, 180.0); assert_eq!(ClockSvg::new(Height(6930000)).minute, 0.0); assert_eq!(ClockSvg::new(Height(6930000)).hour, 0.0); } #[test] fn clock_svg() { assert_regex_match!( ClockSvg::new(Height(6929999)).to_string(), r##"<svg.*<text.*>6929999</text>.* <line y2="-9" transform="rotate\(359.9999480519481\)"/> <line y2="-13" stroke-width="0.6" transform="rotate\(359.9982857142857\)"/> <line y2="-16" stroke="#d00505" stroke-width="0.2" transform="rotate\(179.82142857142858\)"/>.*</svg> "##, ); } } #12,212,463textInscription #12065130#12,065,130htmlregginobili.sats#9,534,936snsregbootleg.sats#9,534,935snsregyandere.sats#9,534,934snsreghanlim.sats#9,534,933snsregdoncic.sats#9,534,932snsregchaeyoung.sats#7,619,771snsregningning.sats#7,619,770snsregyuqi.sats#7,619,769snsregshuhua.sats#7,619,768snsregnayeon.sats#7,619,767snsregchaewon.sats#7,588,910snsregxiaoting.sats#7,588,909snsregheejin.sats#7,588,908snsregkarina.sats#7,588,907snsregyeji.sats#7,588,906snsregyujin.sats#7,588,905snsregsana.sats#7,588,904snsregyunjin.sats#7,588,903snsregsohee.sats#7,588,902snsregwigger.sats#3,295,658snsregaegyo.sats#3,295,657snsregbabymonster.sats#2,156,041snsreghypeboy.sats#2,156,040snsregsosa.sats#2,156,039snsregbaka.sats#2,156,038snsregbaemon.sats#2,156,037snsInscription #1536800#1,536,800htmlInscription #1532083#1,532,083htmlregchink.sats#915,083snsregwonyoung.sats#914,892sns48.85661,2.35222#914,632text39.90421,116.40739#914,114text31.23042,121.47370#913,544text39.03922,125.76252#913,293text35.67619,139.65031#913,196textmint777.pups#790,717brc-20mint777.pups#785,562brc-20Inscription #713861#713,861pngInscription #713860#713,860pngInscription #713852#713,852pngInscription #157659#157,659png