From e1b8ff59c27efbb0fc95b661ace2fe8be751e3a6 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 14 Jan 2020 14:02:42 +0300 Subject: [PATCH] Prevent filling pending_block_operations table for RSK variant --- CHANGELOG.md | 2 +- .../explorer/chain/import/runner/blocks.ex | 42 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b13d14555e..f90788beaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## Current ### Features -- [#2835](https://github.com/poanetwork/blockscout/pull/2835), [#2871](https://github.com/poanetwork/blockscout/pull/2871), [#2872](https://github.com/poanetwork/blockscout/pull/2872), [#2886](https://github.com/poanetwork/blockscout/pull/2886), [#2925](https://github.com/poanetwork/blockscout/pull/2925), [#2936](https://github.com/poanetwork/blockscout/pull/2936) - Add "block_hash" to logs, token_transfers and internal transactions and "pending blocks operations" approach +- [#2835](https://github.com/poanetwork/blockscout/pull/2835), [#2871](https://github.com/poanetwork/blockscout/pull/2871), [#2872](https://github.com/poanetwork/blockscout/pull/2872), [#2886](https://github.com/poanetwork/blockscout/pull/2886), [#2925](https://github.com/poanetwork/blockscout/pull/2925), [#2936](https://github.com/poanetwork/blockscout/pull/2936), [#2949](https://github.com/poanetwork/blockscout/pull/2949) - Add "block_hash" to logs, token_transfers and internal transactions and "pending blocks operations" approach - [#2926](https://github.com/poanetwork/blockscout/pull/2926) - API endpoint: sum balances except burnt address - [#2918](https://github.com/poanetwork/blockscout/pull/2918) - Add tokenID for tokentx API action explicitly diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index 3190c1abae..ddce8d0200 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -310,25 +310,29 @@ defmodule Explorer.Chain.Import.Runner.Blocks do end defp new_pending_operations(repo, nonconsensus_hashes, hashes, %{timeout: timeout, timestamps: timestamps}) do - sorted_pending_ops = - nonconsensus_hashes - |> MapSet.new() - |> MapSet.union(MapSet.new(hashes)) - |> Enum.sort() - |> Enum.map(fn hash -> - %{block_hash: hash, fetch_internal_transactions: true} - end) - - Import.insert_changes_list( - repo, - sorted_pending_ops, - conflict_target: :block_hash, - on_conflict: PendingBlockOperation.default_on_conflict(), - for: PendingBlockOperation, - returning: true, - timeout: timeout, - timestamps: timestamps - ) + if Application.get_env(:explorer, :json_rpc_named_arguments)[:variant] == EthereumJSONRPC.RSK do + {:ok, []} + else + sorted_pending_ops = + nonconsensus_hashes + |> MapSet.new() + |> MapSet.union(MapSet.new(hashes)) + |> Enum.sort() + |> Enum.map(fn hash -> + %{block_hash: hash, fetch_internal_transactions: true} + end) + + Import.insert_changes_list( + repo, + sorted_pending_ops, + conflict_target: :block_hash, + on_conflict: PendingBlockOperation.default_on_conflict(), + for: PendingBlockOperation, + returning: true, + timeout: timeout, + timestamps: timestamps + ) + end end defp delete_address_token_balances(_, [], _), do: {:ok, []}