diff --git a/CHANGELOG.md b/CHANGELOG.md index 811a4a33ff..1cd2df9deb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Fixes +- [#3382](https://github.com/poanetwork/blockscout/pull/3382) - Check ets table exists for know tokens - [#3376](https://github.com/poanetwork/blockscout/pull/3376) - Fix contract nested inputs - [#3375](https://github.com/poanetwork/blockscout/pull/3375) - Prevent terminating of tokens/contracts process - [#3374](https://github.com/poanetwork/blockscout/pull/3374) - Fix find block timestamp query diff --git a/apps/explorer/lib/explorer/known_tokens/known_tokens.ex b/apps/explorer/lib/explorer/known_tokens/known_tokens.ex index aff9dea74b..078e52d1ca 100644 --- a/apps/explorer/lib/explorer/known_tokens/known_tokens.ex +++ b/apps/explorer/lib/explorer/known_tokens/known_tokens.ex @@ -94,13 +94,21 @@ defmodule Explorer.KnownTokens do @spec lookup(String.t()) :: {:ok, Hash.Address.t()} | :error | nil def lookup(symbol) do if store() == :ets && enabled?() do - case :ets.lookup(table_name(), symbol) do - [{_symbol, address} | _] -> Hash.Address.cast(address) - _ -> nil + if ets_table_exists?(table_name()) do + case :ets.lookup(table_name(), symbol) do + [{_symbol, address} | _] -> Hash.Address.cast(address) + _ -> nil + end + else + nil end end end + defp ets_table_exists?(table) do + :ets.whereis(table) !== :undefined + end + @doc false @spec table_name() :: atom() def table_name do