From 598db94f8ba316852a62571d077d5d5ee2d3fa9a Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 6 Aug 2019 11:19:26 +0300 Subject: [PATCH] fix GenesisData process startup --- apps/explorer/config/config.exs | 2 +- apps/explorer/lib/explorer/chain_spec/genesis_data.ex | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 922255184f..a97197e1d5 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -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 diff --git a/apps/explorer/lib/explorer/chain_spec/genesis_data.ex b/apps/explorer/lib/explorer/chain_spec/genesis_data.ex index 6d33d27b3e..e34cbc0504 100644 --- a/apps/explorer/lib/explorer/chain_spec/genesis_data.ex +++ b/apps/explorer/lib/explorer/chain_spec/genesis_data.ex @@ -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