Merge addresses stage with address referencing

pull/9131/head
Qwerty5Uiop 10 months ago
parent 6e2bec2e20
commit 19af21189a
  1. 1
      CHANGELOG.md
  2. 3
      apps/explorer/lib/explorer/chain/import.ex
  3. 26
      apps/explorer/lib/explorer/chain/import/stage/address_referencing.ex
  4. 22
      apps/explorer/lib/explorer/chain/import/stage/addresses.ex
  5. 34
      apps/explorer/lib/explorer/chain/import/stage/addresses_blocks_coin_balances.ex
  6. 4
      apps/explorer/lib/explorer/chain/import/stage/block_following.ex
  7. 4
      apps/explorer/lib/explorer/chain/import/stage/block_pending.ex
  8. 3
      apps/explorer/lib/explorer/chain/import/stage/block_referencing.ex

@ -5,6 +5,7 @@
### Features
- [#9155](https://github.com/blockscout/blockscout/pull/9155) - Allow bypassing avg block time in proxy implementation re-fetch ttl calculation
- [#9131](https://github.com/blockscout/blockscout/pull/9131) - Merge addresses stage with address referencing
- [#9072](https://github.com/blockscout/blockscout/pull/9072) - Add tracing by block logic for geth
- [#9056](https://github.com/blockscout/blockscout/pull/9056) - Noves.fi API proxy

@ -12,8 +12,7 @@ defmodule Explorer.Chain.Import do
require Logger
@stages [
Import.Stage.Addresses,
Import.Stage.AddressReferencing,
Import.Stage.AddressesBlocksCoinBalances,
Import.Stage.BlockReferencing,
Import.Stage.BlockFollowing,
Import.Stage.BlockPending

@ -1,26 +0,0 @@
defmodule Explorer.Chain.Import.Stage.AddressReferencing do
@moduledoc """
Imports any tables that reference `t:Explorer.Chain.Address.t/0` and that were imported by
`Explorer.Chain.Import.Stage.Addresses`.
"""
alias Explorer.Chain.Import.{Runner, Stage}
@behaviour Stage
@impl Stage
def runners,
do: [
Runner.Address.CoinBalances,
Runner.Blocks,
Runner.Address.CoinBalancesDaily
]
@impl Stage
def multis(runner_to_changes_list, options) do
{final_multi, final_remaining_runner_to_changes_list} =
Stage.single_multi(runners(), runner_to_changes_list, options)
{[final_multi], final_remaining_runner_to_changes_list}
end
end

@ -1,22 +0,0 @@
defmodule Explorer.Chain.Import.Stage.Addresses do
@moduledoc """
Imports addresses before anything else that references them because an unused address is still valid and recoverable
if the other stage(s) don't commit.
"""
alias Explorer.Chain.Import.{Runner, Stage}
@behaviour Stage
@runner Runner.Addresses
@impl Stage
def runners, do: [@runner]
@chunk_size 50
@impl Stage
def multis(runner_to_changes_list, options) do
Stage.chunk_every(runner_to_changes_list, @runner, @chunk_size, options)
end
end

@ -0,0 +1,34 @@
defmodule Explorer.Chain.Import.Stage.AddressesBlocksCoinBalances do
@moduledoc """
Import addresses, blocks and balances.
No tables have foreign key to addresses anymore, so it's possible to import addresses along with them.
"""
alias Explorer.Chain.Import.{Runner, Stage}
@behaviour Stage
@addresses_runner Runner.Addresses
@rest_runners [
Runner.Address.CoinBalances,
Runner.Blocks,
Runner.Address.CoinBalancesDaily
]
@impl Stage
def runners, do: [@addresses_runner | @rest_runners]
@addresses_chunk_size 50
@impl Stage
def multis(runner_to_changes_list, options) do
{addresses_multis, remaining_runner_to_changes_list} =
Stage.chunk_every(runner_to_changes_list, Runner.Addresses, @addresses_chunk_size, options)
{final_multi, final_remaining_runner_to_changes_list} =
Stage.single_multi(@rest_runners, remaining_runner_to_changes_list, options)
{[final_multi | addresses_multis], final_remaining_runner_to_changes_list}
end
end

@ -1,9 +1,7 @@
defmodule Explorer.Chain.Import.Stage.BlockFollowing do
@moduledoc """
Imports any tables that follows and cannot be imported at the same time as
those imported by `Explorer.Chain.Import.Stage.Addresses`,
`Explorer.Chain.Import.Stage.AddressReferencing` and
`Explorer.Chain.Import.Stage.BlockReferencing`
those imported by `Explorer.Chain.Import.Stage.AddressesBlocksCoinBalances` and `Explorer.Chain.Import.Stage.BlockReferencing`
"""
alias Explorer.Chain.Import.{Runner, Stage}

@ -2,9 +2,7 @@ defmodule Explorer.Chain.Import.Stage.BlockPending do
@moduledoc """
Imports any tables that uses `Explorer.Chain.PendingBlockOperation` to track
progress and cannot be imported at the same time as those imported by
`Explorer.Chain.Import.Stage.Addresses`,
`Explorer.Chain.Import.Stage.AddressReferencing` and
`Explorer.Chain.Import.Stage.BlockReferencing`
`Explorer.Chain.Import.Stage.AddressesBlocksCoinBalances` and `Explorer.Chain.Import.Stage.BlockReferencing`
"""
alias Explorer.Chain.Import.{Runner, Stage}

@ -1,8 +1,7 @@
defmodule Explorer.Chain.Import.Stage.BlockReferencing do
@moduledoc """
Imports any tables that reference `t:Explorer.Chain.Block.t/0` and that were
imported by `Explorer.Chain.Import.Stage.Addresses` and
`Explorer.Chain.Import.Stage.AddressReferencing`.
imported by `Explorer.Chain.Import.Stage.AddressesBlocksCoinBalances`.
"""
alias Explorer.Chain.Import.{Runner, Stage}

Loading…
Cancel
Save