@@ -47,6 +47,7 @@ pub fn read_compact_size<R: Read>(reader: &mut R) -> Result<u64, io::Error> {
4747pub struct Hints {
4848 map : BTreeMap < BlockHeight , Vec < u64 > > ,
4949 assume_valid : BlockHash ,
50+ stop_height : BlockHeight ,
5051}
5152
5253impl Hints {
@@ -56,6 +57,8 @@ impl Hints {
5657 pub fn from_file < R : Read > ( reader : & mut R ) -> Self {
5758 let mut map = BTreeMap :: new ( ) ;
5859 let mut height = 1 ;
60+ let mut stop_height = [ 0 ; 4 ] ;
61+ reader. read_exact ( & mut stop_height) . expect ( "empty file" ) ;
5962 let mut assume_valid = [ 0 ; 32 ] ;
6063 reader. read_exact ( & mut assume_valid) . expect ( "empty file" ) ;
6164 while let Ok ( count) = read_compact_size ( reader) {
@@ -67,14 +70,23 @@ impl Hints {
6770 map. insert ( height, offsets) ;
6871 height += 1 ;
6972 }
70- Self { map, assume_valid }
73+ Self {
74+ map,
75+ assume_valid,
76+ stop_height : BlockHeight :: from_le_bytes ( stop_height) ,
77+ }
7178 }
7279
7380 /// Get the last hash encoded in the hintfile.
7481 pub fn stop_hash ( & self ) -> BlockHash {
7582 self . assume_valid
7683 }
7784
85+ /// Get the stop height of the hint file.
86+ pub fn stop_height ( & self ) -> BlockHeight {
87+ self . stop_height
88+ }
89+
7890 /// # Panics
7991 ///
8092 /// If there are no offset present at that height, aka an overflow, or the entry has already
0 commit comments