Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Commit

Permalink
Merge pull request blockscout#6449 from blockscout/fix-min-missing-bl…
Browse files Browse the repository at this point in the history
…ock-number

Search min_missing_block_number from zero
  • Loading branch information
vbaranov authored Nov 15, 2022
2 parents 40cd801 + 52d6930 commit bdecca9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- [#6223](https://github.com/blockscout/blockscout/pull/6223) - Fix coin_id test
- [#6336](https://github.com/blockscout/blockscout/pull/6336) - Fix sending request on each key in token search
- [#6327](https://github.com/blockscout/blockscout/pull/6327) - Fix and refactor address logs page and search
- [#6449](https://github.com/blockscout/blockscout/pull/6449) - Search min_missing_block_number from zero

### Chore

Expand Down
8 changes: 1 addition & 7 deletions apps/explorer/lib/explorer/chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3009,23 +3009,17 @@ defmodule Explorer.Chain do
def fetch_min_missing_block_cache do
max_block_number = BlockNumber.get_max()

min_missing_block_number =
"min_missing_block_number"
|> Chain.get_last_fetched_counter()
|> Decimal.to_integer()

if max_block_number > 0 do
query =
from(b in Block,
right_join:
missing_range in fragment(
"""
(SELECT b1.number
FROM generate_series((?)::integer, (?)::integer) AS b1(number)
FROM generate_series(0, (?)::integer) AS b1(number)
WHERE NOT EXISTS
(SELECT 1 FROM blocks b2 WHERE b2.number=b1.number AND b2.consensus))
""",
^min_missing_block_number,
^max_block_number
),
on: b.number == missing_range.number,
Expand Down

0 comments on commit bdecca9

Please sign in to comment.