skip cache update if there are no blocks inserted

Sometimes due to some error (mostly network) if may
not fetch any data when indexing block. If block cache update
is triggered it fails.

This PR check if list is passed to cache update function.
pull/2617/head
Ayrat Badykov 5 years ago
parent d19e4811f5
commit 0e736637a7
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 4
      apps/indexer/lib/indexer/block/fetcher.ex

@ -183,7 +183,7 @@ defmodule Indexer.Block.Fetcher do
end
end
defp update_block_cache(blocks) do
defp update_block_cache(blocks) when is_list(blocks) do
max_block = Enum.max_by(blocks, fn block -> block.number end)
min_block = Enum.min_by(blocks, fn block -> block.number end)
@ -192,6 +192,8 @@ defmodule Indexer.Block.Fetcher do
BlocksCache.update(blocks)
end
defp update_block_cache(_), do: :ok
defp update_transactions_cache(transactions) do
Transactions.update(transactions)
end

Loading…
Cancel
Save