Merge pull request #3382 from poanetwork/vb-check-ets-table-for-known-tokens

Check ets table exists for known tokens
pull/3383/head
Victor Baranov 4 years ago committed by GitHub
commit 78ecca256c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      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
case :ets.lookup(table_name(), symbol) do if ets_table_exists?(table_name()) do
[{_symbol, address} | _] -> Hash.Address.cast(address) case :ets.lookup(table_name(), symbol) do
_ -> nil [{_symbol, address} | _] -> Hash.Address.cast(address)
_ -> nil
end
else
nil
end 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