Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Sep 3, 2019
1 parent eeba5a3 commit b873c4d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ impl Chain {
min_height: Option<u64>,
max_height: Option<u64>,
) -> Result<BlockHeader, Error> {
let txhashset = self.txhashset.read();
let header_pmmr = self.header_pmmr.read();

let mut min = min_height.unwrap_or(0).saturating_sub(1);
let mut max = match max_height {
Expand All @@ -1344,11 +1344,13 @@ impl Chain {

loop {
let search_height = max - (max - min) / 2;
let h = txhashset.get_header_by_height(search_height)?;
let hash = header_pmmr.get_header_hash_by_height(search_height)?;
let h = self.get_block_header(&hash)?;
if search_height == 0 {
return Ok(h);
}
let h_prev = txhashset.get_header_by_height(search_height - 1)?;
let hash_prev = header_pmmr.get_header_hash_by_height(search_height - 1)?;
let h_prev = self.get_block_header(&hash_prev)?;
if kernel_mmr_index > h.kernel_mmr_size {
min = search_height;
} else if kernel_mmr_index < h_prev.kernel_mmr_size {
Expand Down

0 comments on commit b873c4d

Please sign in to comment.