Check ets table exists for know tokens

pull/3382/head
Victor Baranov 4 years ago
parent 7770eb6188
commit 4df9b27b47
  1. 1
      CHANGELOG.md
  2. 8
      apps/explorer/lib/explorer/known_tokens/known_tokens.ex

@ -9,6 +9,7 @@
### Fixes ### 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 - [#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 - [#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 - [#3374](https://github.com/poanetwork/blockscout/pull/3374) - Fix find block timestamp query

@ -94,13 +94,21 @@ defmodule Explorer.KnownTokens do
@spec lookup(String.t()) :: {:ok, Hash.Address.t()} | :error | nil @spec lookup(String.t()) :: {:ok, Hash.Address.t()} | :error | nil
def lookup(symbol) do def lookup(symbol) do
if store() == :ets && enabled?() do if store() == :ets && enabled?() do
if ets_table_exists?(table_name()) do
case :ets.lookup(table_name(), symbol) do case :ets.lookup(table_name(), symbol) do
[{_symbol, address} | _] -> Hash.Address.cast(address) [{_symbol, address} | _] -> Hash.Address.cast(address)
_ -> nil _ -> nil
end end
else
nil
end
end end
end end
defp ets_table_exists?(table) do
:ets.whereis(table) !== :undefined
end
@doc false @doc false
@spec table_name() :: atom() @spec table_name() :: atom()
def table_name do def table_name do

Loading…
Cancel
Save