From 3d0d0f6209c326e4e691305b4f3fae4c47737f07 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 17 Jan 2019 19:00:20 +0300 Subject: [PATCH] return async_import_internal_transactions --- .../lib/indexer/block/catchup/fetcher.ex | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/indexer/lib/indexer/block/catchup/fetcher.ex b/apps/indexer/lib/indexer/block/catchup/fetcher.ex index 8ca6371f5c..233fd5f7e4 100644 --- a/apps/indexer/lib/indexer/block/catchup/fetcher.ex +++ b/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)