Add Explorer.Tags.AddressTag.Cataloger shutdown

pull/6933/head
Nikita Pozdniakov 2 years ago
parent c5b51f8363
commit 9689ecf944
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 18
      apps/block_scout_web/lib/block_scout_web/notifier.ex
  2. 1
      apps/block_scout_web/lib/block_scout_web/realtime_event_handler.ex
  3. 14
      apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex
  4. 4
      apps/explorer/lib/explorer/tags/address_tag_cataloger.ex

@ -14,6 +14,7 @@ defmodule BlockScoutWeb.Notifier do
Endpoint Endpoint
} }
alias BlockScoutWeb.API.V2.TransactionView
alias Explorer.{Chain, Market, Repo} alias Explorer.{Chain, Market, Repo}
alias Explorer.Chain.{Address, InternalTransaction, TokenTransfer, Transaction} alias Explorer.Chain.{Address, InternalTransaction, TokenTransfer, Transaction}
alias Explorer.Chain.Supply.RSK alias Explorer.Chain.Supply.RSK
@ -136,6 +137,23 @@ defmodule BlockScoutWeb.Notifier do
}) })
end end
defp debug(value, key) do
require Logger
Logger.configure(truncate: :infinity)
Logger.info(key)
Logger.info(Kernel.inspect(value, limit: :infinity, printable_limit: :infinity))
value
end
def handle_event({:chain_event, :internal_transactions, :on_demand, [internal_transaction]}) do
internal_transactions = Chain.all_transaction_to_internal_transactions(internal_transaction.transaction_hash)
Endpoint.broadcast("transactions:#{internal_transaction.transaction_hash}", "raw_trace", %{
raw_trace:
TransactionView.render("raw_trace.json", %{internal_transactions: internal_transactions}) |> debug("render")
})
end
def handle_event({:chain_event, :internal_transactions, :realtime, internal_transactions}) do def handle_event({:chain_event, :internal_transactions, :realtime, internal_transactions}) do
internal_transactions internal_transactions
|> Stream.map( |> Stream.map(

@ -21,6 +21,7 @@ defmodule BlockScoutWeb.RealtimeEventHandler do
Subscriber.to(:block_rewards, :realtime) Subscriber.to(:block_rewards, :realtime)
Subscriber.to(:blocks, :realtime) Subscriber.to(:blocks, :realtime)
Subscriber.to(:internal_transactions, :realtime) Subscriber.to(:internal_transactions, :realtime)
Subscriber.to(:internal_transactions, :on_demand)
Subscriber.to(:token_transfers, :realtime) Subscriber.to(:token_transfers, :realtime)
Subscriber.to(:transactions, :realtime) Subscriber.to(:transactions, :realtime)
Subscriber.to(:addresses, :on_demand) Subscriber.to(:addresses, :on_demand)

@ -9,6 +9,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
alias Ecto.Adapters.SQL alias Ecto.Adapters.SQL
alias Ecto.{Changeset, Multi, Repo} alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.{Block, Hash, Import, InternalTransaction, PendingBlockOperation, Transaction} alias Explorer.Chain.{Block, Hash, Import, InternalTransaction, PendingBlockOperation, Transaction}
alias Explorer.Chain.Events.Publisher
alias Explorer.Chain.Import.Runner alias Explorer.Chain.Import.Runner
alias Explorer.Prometheus.Instrumenter alias Explorer.Prometheus.Instrumenter
alias Explorer.Repo, as: ExplorerRepo alias Explorer.Repo, as: ExplorerRepo
@ -177,11 +178,14 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do
internal_transactions_params = Enum.filter(changes_list, &Map.has_key?(&1, :type)) internal_transactions_params = Enum.filter(changes_list, &Map.has_key?(&1, :type))
# Enforce ShareLocks tables order (see docs: sharelocks.md) # Enforce ShareLocks tables order (see docs: sharelocks.md)
Multi.new() with {:ok, data} <-
|> Multi.run(:internal_transactions, fn repo, _ -> Multi.new()
insert(repo, internal_transactions_params, insert_options) |> Multi.run(:internal_transactions, fn repo, _ ->
end) insert(repo, internal_transactions_params, insert_options)
|> ExplorerRepo.transaction() end)
|> ExplorerRepo.transaction() do
Publisher.broadcast(data, :on_demand)
end
end end
@impl Runner @impl Runner

@ -3,7 +3,7 @@ defmodule Explorer.Tags.AddressTag.Cataloger do
Actualizes address tags. Actualizes address tags.
""" """
use GenServer use GenServer, restart: :transient
alias Explorer.Chain.Fetcher.FetchValidatorInfoOnDemand alias Explorer.Chain.Fetcher.FetchValidatorInfoOnDemand
alias Explorer.EnvVarTranslator alias Explorer.EnvVarTranslator
@ -58,7 +58,7 @@ defmodule Explorer.Tags.AddressTag.Cataloger do
end end
end) end)
{:noreply, state} {:stop, :normal, state}
end end
defp tag_name_to_env_var_part(tag_name) do defp tag_name_to_env_var_part(tag_name) do

Loading…
Cancel
Save