|
|
|
@ -45,6 +45,13 @@ defmodule Indexer.Temporary.AddressesWithoutCode do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def fix_transaction_without_to_address_and_created_contract_address(fetcher) do |
|
|
|
|
Logger.debug( |
|
|
|
|
[ |
|
|
|
|
"Started fix_transaction_without_to_address_and_created_contract_address" |
|
|
|
|
], |
|
|
|
|
fetcher: :addresses_without_code |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
query = |
|
|
|
|
from(block in Block, |
|
|
|
|
left_join: transaction in Transaction, |
|
|
|
@ -56,23 +63,23 @@ defmodule Indexer.Temporary.AddressesWithoutCode do |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
process_query(query, fetcher) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp process_query(query, fetcher) do |
|
|
|
|
query_stream = Repo.stream(query, max_rows: @batch_size) |
|
|
|
|
|
|
|
|
|
stream = |
|
|
|
|
TaskSupervisor |
|
|
|
|
|> Task.Supervisor.async_stream_nolink( |
|
|
|
|
query_stream, |
|
|
|
|
fn block -> refetch_block(block, fetcher) end, |
|
|
|
|
@task_options |
|
|
|
|
Logger.debug( |
|
|
|
|
[ |
|
|
|
|
"Started fix_transaction_without_to_address_and_created_contract_address" |
|
|
|
|
], |
|
|
|
|
fetcher: :addresses_without_code |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
Repo.transaction(fn -> Stream.run(stream) end) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def fix_addresses_with_creation_transaction_but_without_code(fetcher) do |
|
|
|
|
Logger.debug( |
|
|
|
|
[ |
|
|
|
|
"Started fix_addresses_with_creation_transaction_but_without_code" |
|
|
|
|
], |
|
|
|
|
fetcher: :addresses_without_code |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
second_query = |
|
|
|
|
from(block in Block, |
|
|
|
|
left_join: transaction in Transaction, |
|
|
|
@ -87,10 +94,45 @@ defmodule Indexer.Temporary.AddressesWithoutCode do |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
process_query(second_query, fetcher) |
|
|
|
|
|
|
|
|
|
Logger.debug( |
|
|
|
|
[ |
|
|
|
|
"Finished fix_addresses_with_creation_transaction_but_without_code" |
|
|
|
|
], |
|
|
|
|
fetcher: :addresses_without_code |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp process_query(query, fetcher) do |
|
|
|
|
query_stream = Repo.stream(query, max_rows: @batch_size) |
|
|
|
|
|
|
|
|
|
stream = |
|
|
|
|
TaskSupervisor |
|
|
|
|
|> Task.Supervisor.async_stream_nolink( |
|
|
|
|
query_stream, |
|
|
|
|
fn block -> refetch_block(block, fetcher) end, |
|
|
|
|
@task_options |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
Repo.transaction(fn -> Stream.run(stream) end) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def refetch_block(block, fetcher) do |
|
|
|
|
Logger.debug( |
|
|
|
|
[ |
|
|
|
|
"Processing block #{to_string(block.hash)} #{block.number}" |
|
|
|
|
], |
|
|
|
|
fetcher: :addresses_without_code |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
Fetcher.fetch_and_import_block(block.number, fetcher, false) |
|
|
|
|
|
|
|
|
|
Logger.debug( |
|
|
|
|
[ |
|
|
|
|
"Finished processing block #{to_string(block.hash)} #{block.number}" |
|
|
|
|
], |
|
|
|
|
fetcher: :addresses_without_code |
|
|
|
|
) |
|
|
|
|
rescue |
|
|
|
|
e -> |
|
|
|
|
Logger.debug( |
|
|
|
|