Merge pull request #2949 from poanetwork/vb-prevent-fill-pbo-for-rsk-variant

Prevent filling pending_block_operations table for RSK variant
pull/2956/head
Victor Baranov 5 years ago committed by GitHub
commit 130a4084ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 42
      apps/explorer/lib/explorer/chain/import/runner/blocks.ex

@ -1,7 +1,7 @@
## Current ## Current
### Features ### 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 - [#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 - [#2918](https://github.com/poanetwork/blockscout/pull/2918) - Add tokenID for tokentx API action explicitly

@ -310,25 +310,29 @@ defmodule Explorer.Chain.Import.Runner.Blocks do
end end
defp new_pending_operations(repo, nonconsensus_hashes, hashes, %{timeout: timeout, timestamps: timestamps}) do defp new_pending_operations(repo, nonconsensus_hashes, hashes, %{timeout: timeout, timestamps: timestamps}) do
sorted_pending_ops = if Application.get_env(:explorer, :json_rpc_named_arguments)[:variant] == EthereumJSONRPC.RSK do
nonconsensus_hashes {:ok, []}
|> MapSet.new() else
|> MapSet.union(MapSet.new(hashes)) sorted_pending_ops =
|> Enum.sort() nonconsensus_hashes
|> Enum.map(fn hash -> |> MapSet.new()
%{block_hash: hash, fetch_internal_transactions: true} |> MapSet.union(MapSet.new(hashes))
end) |> Enum.sort()
|> Enum.map(fn hash ->
Import.insert_changes_list( %{block_hash: hash, fetch_internal_transactions: true}
repo, end)
sorted_pending_ops,
conflict_target: :block_hash, Import.insert_changes_list(
on_conflict: PendingBlockOperation.default_on_conflict(), repo,
for: PendingBlockOperation, sorted_pending_ops,
returning: true, conflict_target: :block_hash,
timeout: timeout, on_conflict: PendingBlockOperation.default_on_conflict(),
timestamps: timestamps for: PendingBlockOperation,
) returning: true,
timeout: timeout,
timestamps: timestamps
)
end
end end
defp delete_address_token_balances(_, [], _), do: {:ok, []} defp delete_address_token_balances(_, [], _), do: {:ok, []}

Loading…
Cancel
Save