return async_import_internal_transactions

pull/1353/head
Ayrat Badykov 6 years ago
parent fdc57c8488
commit 3d0d0f6209
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 25
      apps/indexer/lib/indexer/block/catchup/fetcher.ex

@ -12,7 +12,7 @@ defmodule Indexer.Block.Catchup.Fetcher do
alias Ecto.Changeset
alias Explorer.Chain
alias Explorer.Chain.Transaction
alias Explorer.Chain.{Hash, Transaction}
alias Indexer.{Block, Code, InternalTransaction, Sequence, TokenBalance, Tracer}
alias Indexer.Memory.Shrinkable
@ -131,6 +131,7 @@ defmodule Indexer.Block.Catchup.Fetcher do
defp async_import_remaining_block_data(imported, options) do
async_import_coin_balances(imported, options)
async_import_created_contract_codes(imported)
async_import_internal_transactions(imported)
async_import_tokens(imported)
async_import_token_balances(imported)
async_import_uncles(imported)
@ -142,34 +143,36 @@ defmodule Indexer.Block.Catchup.Fetcher do
%Transaction{
block_number: block_number,
hash: hash,
created_contract_address_hash: <<_::bytes>> = created_contract_address_hash,
created_contract_address_hash: %Hash{} = created_contract_address_hash,
created_contract_code_indexed_at: nil,
internal_transactions_indexed_at: nil
} ->
[%{block_number: block_number, hash: hash, created_contract_address_hash: created_contract_address_hash}]
_ ->
%Transaction{internal_transactions_indexed_at: %DateTime{}} ->
[]
%Transaction{created_contract_address_hash: nil} ->
[]
end)
|> Code.Fetcher.async_fetch(10_000)
end
defp async_import_created_contract_codes(_), do: :ok
defp async_import_internal_transactions(%{transactions: transactions}) do
transactions
|> Enum.flat_map(fn
%Transaction{
block_number: block_number,
index: index,
hash: hash,
internal_transactions_indexed_at: nil
} ->
%Transaction{block_number: block_number, index: index, hash: hash, internal_transactions_indexed_at: nil} ->
[%{block_number: block_number, index: index, hash: hash}]
_ ->
%Transaction{internal_transactions_indexed_at: %DateTime{}} ->
[]
end)
|> InternalTransaction.Fetcher.async_fetch(10_000)
end
defp async_import_created_contract_codes(_), do: :ok
defp async_import_internal_transactions(_), do: :ok
defp async_import_token_balances(%{address_token_balances: token_balances}) do
TokenBalance.Fetcher.async_fetch(token_balances)

Loading…
Cancel
Save