From 626e208cfc4553f088a28aa3f4095502efec49d5 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 27 Feb 2020 16:06:58 +0300 Subject: [PATCH] Remove insdexing status top alert from Ganache variant --- CHANGELOG.md | 1 + apps/explorer/lib/explorer/chain.ex | 31 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0edcae9e86..fccf655c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - [#2883](https://github.com/poanetwork/blockscout/pull/2883) - Fix long contracts names ### Chore +- [#3032](https://github.com/poanetwork/blockscout/pull/3032) - Remove indexing status alert for Ganache variant - [#3030](https://github.com/poanetwork/blockscout/pull/3030) - Remove default websockets URL from config - [#2995](https://github.com/poanetwork/blockscout/pull/2995) - Support API_PATH env var in Docker file diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 848e37f576..fe9b15bcac 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -846,20 +846,27 @@ defmodule Explorer.Chain do """ @spec finished_indexing?() :: boolean() def finished_indexing? do - with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, - min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do - query = - from( - b in Block, - join: pending_ops in assoc(b, :pending_operations), - where: pending_ops.fetch_internal_transactions, - where: b.consensus and b.number == ^min_block_number - ) + json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments) + variant = Keyword.fetch!(json_rpc_named_arguments, :variant) - !Repo.exists?(query) + if variant == EthereumJSONRPC.Ganache do + true else - {:transactions_exist, false} -> true - nil -> false + with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, + min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do + query = + from( + b in Block, + join: pending_ops in assoc(b, :pending_operations), + where: pending_ops.fetch_internal_transactions, + where: b.consensus and b.number == ^min_block_number + ) + + !Repo.exists?(query) + else + {:transactions_exist, false} -> true + nil -> false + end end end