@@ -3,7 +3,8 @@ use std::{
33 io:: { self , Read , Write } ,
44} ;
55
6- use bitcoin:: { consensus, BlockHash , BlockHeight , BlockHeightInterval } ;
6+ type BlockHash = [ u8 ; 32 ] ;
7+ type BlockHeight = u32 ;
78
89pub fn write_compact_size < W : Write > ( value : u64 , writer : & mut W ) -> Result < ( ) , io:: Error > {
910 match value {
@@ -54,20 +55,17 @@ impl Hints {
5455 // Panics when expected data is not present, or the hintfile overflows the maximum blockheight
5556 pub fn from_file < R : Read > ( reader : & mut R ) -> Self {
5657 let mut map = BTreeMap :: new ( ) ;
57- let mut height = BlockHeight :: from_u32 ( 1 ) ;
58- let mut buf = [ 0 ; 32 ] ;
59- reader. read_exact ( & mut buf) . expect ( "empty file" ) ;
60- let assume_valid = consensus:: deserialize :: < BlockHash > ( & buf) . expect ( "empty file." ) ;
58+ let mut height = 1 ;
59+ let mut assume_valid = [ 0 ; 32 ] ;
60+ reader. read_exact ( & mut assume_valid) . expect ( "empty file" ) ;
6161 while let Ok ( count) = read_compact_size ( reader) {
6262 // panics on 32 bit machines
6363 let mut offsets = Vec :: with_capacity ( count as usize ) ;
6464 for _ in 0 ..count {
6565 offsets. push ( read_compact_size ( reader) . expect ( "unexpected end of hintfile" ) ) ;
6666 }
6767 map. insert ( height, offsets) ;
68- height = height
69- . checked_add ( BlockHeightInterval :: from_u32 ( 1 ) )
70- . expect ( "hintfile absurdly large." )
68+ height += 1 ;
7169 }
7270 Self { map, assume_valid }
7371 }
0 commit comments