fix GenesisData process startup

pull/2499/head
Ayrat Badykov 5 years ago
parent 2a5e2b439b
commit 598db94f8b
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 2
      apps/explorer/config/config.exs
  2. 7
      apps/explorer/lib/explorer/chain_spec/genesis_data.ex

@ -27,7 +27,7 @@ config :explorer, Explorer.Counters.AverageBlockTime,
enabled: true,
period: average_block_period
config :explorer, Explorer.ChainSpec.GenesisData, chain_spec_path: System.get_env("CHAIN_SPEC_PATH")
config :explorer, Explorer.ChainSpec.GenesisData, enabled: true, chain_spec_path: System.get_env("CHAIN_SPEC_PATH")
config :explorer, Explorer.Chain.Cache.BlockNumber, enabled: true

@ -11,9 +11,14 @@ defmodule Explorer.ChainSpec.GenesisData do
@interval :timer.minutes(2)
def start_link(opts) do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
end
@impl GenServer
def init(_) do
:timer.send_interval(@interval, :import)
Process.send_after(self(), :import, @interval)
{:ok, %{}}
end
@ -58,6 +63,8 @@ defmodule Explorer.ChainSpec.GenesisData do
{:ok, _} = Importer.import_genesis_coin_balances(chain_spec)
end)
else
Logger.warn(fn -> "Failed to fetch genesis data. Chain spec path is not set." end)
end
end
end

Loading…
Cancel
Save