11use eframe:: egui;
22use human_size:: { Byte , Kibibyte , Mebibyte , SpecificSize } ;
3- use thunder:: { bip300301:: bitcoin, state:: State , types:: GetValue } ;
3+ use thunder:: {
4+ bip300301:: bitcoin,
5+ state:: State ,
6+ types:: { Body , GetValue , Header } ,
7+ } ;
48
59use crate :: app:: App ;
610
@@ -15,8 +19,17 @@ impl BlockExplorer {
1519
1620 pub fn show ( & mut self , app : & mut App , ui : & mut egui:: Ui ) {
1721 let max_height = app. node . get_height ( ) . unwrap_or ( 0 ) ;
18- let header = app. node . get_header ( self . height ) . ok ( ) . flatten ( ) ;
19- let body = app. node . get_body ( self . height ) . ok ( ) . flatten ( ) ;
22+ let block: Option < ( Header , Body ) > = {
23+ if let Ok ( Some ( block_hash) ) =
24+ app. node . try_get_block_hash ( self . height )
25+ && let Ok ( header) = app. node . get_header ( block_hash)
26+ && let Ok ( body) = app. node . get_body ( block_hash)
27+ {
28+ Some ( ( header, body) )
29+ } else {
30+ None
31+ }
32+ } ;
2033 egui:: CentralPanel :: default ( ) . show_inside ( ui, |ui| {
2134 ui. heading ( "Block" ) ;
2235 ui. horizontal ( |ui| {
@@ -31,7 +44,7 @@ impl BlockExplorer {
3144 self . height = max_height;
3245 }
3346 } ) ;
34- if let ( Some ( header) , Some ( body) ) = ( header , body ) {
47+ if let Some ( ( header, body) ) = block {
3548 let hash = & format ! ( "{}" , header. hash( ) ) ;
3649 let merkle_root = & format ! ( "{}" , header. merkle_root) ;
3750 let prev_side_hash = & format ! ( "{}" , header. prev_side_hash) ;
0 commit comments