Skip to content

Commit

Permalink
Fix off by one bug in index::blocks (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
terror committed Aug 17, 2022
1 parent bbf511d commit fac929b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl Index {
let height_to_hash = rtx.0.open_table(HEIGHT_TO_HASH)?;

let mut cursor = height_to_hash
.range(height.saturating_sub(take)..=height)?
.range(height.saturating_sub(take.saturating_sub(1))..=height)?
.rev();

while let Some(next) = cursor.next() {
Expand Down
2 changes: 1 addition & 1 deletion tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn root_block_limit() {
state.request_regex(
"/",
200,
".*<ul>\n( <li>[[:digit:]]{3} - <a href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>\n){101}</ul>.*"
".*<ul>\n( <li>[[:digit:]]{3} - <a href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>\n){100}</ul>.*"
);
}

Expand Down

0 comments on commit fac929b

Please sign in to comment.