check if ets table exist

pull/1388/head
Ayrat Badykov 6 years ago
parent 1068c5f775
commit 12f1b200b3
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 4
      apps/explorer/lib/explorer/chain/block_number_cache.ex

@ -13,15 +13,17 @@ defmodule Explorer.Chain.BlockNumberCache do
@spec setup(Keyword.t()) :: :ok @spec setup(Keyword.t()) :: :ok
def setup(opts \\ []) do def setup(opts \\ []) do
if :ets.whereis(@tab) == :undefined do
:ets.new(@tab, [ :ets.new(@tab, [
:set, :set,
:named_table, :named_table,
:public, :public,
write_concurrency: true write_concurrency: true
]) ])
end
update_cache()
setup_opts(opts) setup_opts(opts)
update_cache()
:ok :ok
end end

Loading…
Cancel
Save