Move MissingRangesCollector init logic to handle_continue

pull/7724/head
Qwerty5Uiop 1 year ago
parent e337fefa53
commit 6f564f9918
  1. 1
      CHANGELOG.md
  2. 7
      apps/indexer/lib/indexer/block/catchup/missing_ranges_collector.ex
  3. 3
      apps/indexer/test/indexer/block/catchup/bound_interval_supervisor_test.exs
  4. 6
      apps/indexer/test/indexer/block/catchup/fetcher_test.exs

@ -32,6 +32,7 @@
- [#7516](https://github.com/blockscout/blockscout/pull/7516) - Fix shrinking logo in Safari - [#7516](https://github.com/blockscout/blockscout/pull/7516) - Fix shrinking logo in Safari
- [#7590](https://github.com/blockscout/blockscout/pull/7590) - Drop genesis block in internal transactions fetcher - [#7590](https://github.com/blockscout/blockscout/pull/7590) - Drop genesis block in internal transactions fetcher
- [#7639](https://github.com/blockscout/blockscout/pull/7639) - Fix contract creation transactions - [#7639](https://github.com/blockscout/blockscout/pull/7639) - Fix contract creation transactions
- [#7724](https://github.com/blockscout/blockscout/pull/7724) - Move MissingRangesCollector init logic to handle_continue
### Chore ### Chore

@ -22,7 +22,12 @@ defmodule Indexer.Block.Catchup.MissingRangesCollector do
@impl true @impl true
def init(_) do def init(_) do
{:ok, define_init()} {:ok, %{min_fetched_block_number: nil, max_fetched_block_number: nil}, {:continue, :ok}}
end
@impl true
def handle_continue(:ok, _state) do
{:noreply, define_init()}
end end
defp define_init do defp define_init do

@ -8,7 +8,6 @@ defmodule Indexer.Block.Catchup.BoundIntervalSupervisorTest do
alias Explorer.Chain.Block alias Explorer.Chain.Block
alias Explorer.Repo alias Explorer.Repo
alias Explorer.Utility.MissingRangesManipulator
alias Indexer.BoundInterval alias Indexer.BoundInterval
alias Indexer.Block.Catchup alias Indexer.Block.Catchup
alias Indexer.Block.Catchup.MissingRangesCollector alias Indexer.Block.Catchup.MissingRangesCollector
@ -533,6 +532,8 @@ defmodule Indexer.Block.Catchup.BoundIntervalSupervisorTest do
# from `setup :state` # from `setup :state`
assert_received :catchup_index assert_received :catchup_index
Process.sleep(50)
assert {:noreply, assert {:noreply,
%Catchup.BoundIntervalSupervisor{fetcher: %Catchup.Fetcher{}, task: %Task{pid: pid, ref: ref}} = %Catchup.BoundIntervalSupervisor{fetcher: %Catchup.Fetcher{}, task: %Task{pid: pid, ref: ref}} =
catchup_index_state} = Catchup.BoundIntervalSupervisor.handle_info(:catchup_index, state) catchup_index_state} = Catchup.BoundIntervalSupervisor.handle_info(:catchup_index, state)

@ -285,6 +285,8 @@ defmodule Indexer.Block.Catchup.FetcherTest do
assert count(Chain.Block) == 0 assert count(Chain.Block) == 0
Process.sleep(50)
assert %{first_block_number: ^block_number, last_block_number: 0, missing_block_count: 2, shrunk: false} = assert %{first_block_number: ^block_number, last_block_number: 0, missing_block_count: 2, shrunk: false} =
Fetcher.task(%Fetcher{ Fetcher.task(%Fetcher{
block_fetcher: %Block.Fetcher{ block_fetcher: %Block.Fetcher{
@ -438,6 +440,8 @@ defmodule Indexer.Block.Catchup.FetcherTest do
Process.register(pid, BlockReward) Process.register(pid, BlockReward)
Process.sleep(50)
assert %{first_block_number: ^block_number, last_block_number: 0, missing_block_count: 2, shrunk: false} = assert %{first_block_number: ^block_number, last_block_number: 0, missing_block_count: 2, shrunk: false} =
Fetcher.task(%Fetcher{ Fetcher.task(%Fetcher{
block_fetcher: %Block.Fetcher{ block_fetcher: %Block.Fetcher{
@ -586,6 +590,8 @@ defmodule Indexer.Block.Catchup.FetcherTest do
Process.register(pid, BlockReward) Process.register(pid, BlockReward)
Process.sleep(50)
assert %{first_block_number: ^block_number, last_block_number: 0, missing_block_count: 2, shrunk: false} = assert %{first_block_number: ^block_number, last_block_number: 0, missing_block_count: 2, shrunk: false} =
Fetcher.task(%Fetcher{ Fetcher.task(%Fetcher{
block_fetcher: %Block.Fetcher{ block_fetcher: %Block.Fetcher{

Loading…
Cancel
Save