Merge branch 'master' into list-logs-endpoint-performance

pull/2014/head
Victor Baranov 6 years ago committed by GitHub
commit 705a14514e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 2
      apps/explorer/priv/repo/migrations/20190513134025_add_refetch_needed_to_block.exs
  3. 11
      apps/indexer/lib/indexer/temporary/blocks_transactions_mismatch.ex

@ -18,7 +18,8 @@
- [#1999](https://github.com/poanetwork/blockscout/pull/1999) - load data async on addresses page
- [#2002](https://github.com/poanetwork/blockscout/pull/2002) - Get estimated count of blocks when cache is empty
- [#1807](https://github.com/poanetwork/blockscout/pull/1807) - New theming capabilites.
- [#2040](https://github.com/poanetwork/blockscout/pull/2040) - Verification links to other explorers for ETH
- [#2040](https://github.com/poanetwork/blockscout/pull/2040) - Verification links to other explorers for ETH
- [#2012](https://github.com/poanetwork/blockscout/pull/2012) - make all pages pagination async
### Fixes
- [#2043](https://github.com/poanetwork/blockscout/pull/2043) - Fixed modal dialog width for 'verify other explorers'
@ -45,6 +46,7 @@
- [#2008](https://github.com/poanetwork/blockscout/pull/2008) - add new function clause for xDai network beneficiaries
- [#2009](https://github.com/poanetwork/blockscout/pull/2009) - addresses page improvements
- [#2014](https://github.com/poanetwork/blockscout/pull/2014) - fix: use better queries for listLogs endpoint
- [#2027](https://github.com/poanetwork/blockscout/pull/2027) - fix: `BlocksTransactionsMismatch` ignoring blocks without transactions
### Chore

@ -6,6 +6,6 @@ defmodule Explorer.Repo.Migrations.AddRefetchNeededToBlock do
add(:refetch_needed, :boolean, default: false)
end
execute("UPDATE blocks SET refetch_needed = TRUE;", "")
execute("UPDATE blocks SET refetch_needed = TRUE WHERE consensus", "")
end
end

@ -51,7 +51,7 @@ defmodule Indexer.Temporary.BlocksTransactionsMismatch do
def init(initial, reducer, _) do
query =
from(block in Block,
join: transactions in assoc(block, :transactions),
left_join: transactions in assoc(block, :transactions),
where: block.consensus and block.refetch_needed,
group_by: block.hash,
select: {block, count(transactions.hash)}
@ -81,14 +81,19 @@ defmodule Indexer.Temporary.BlocksTransactionsMismatch do
defp run_blocks(%Blocks{blocks_params: []}, blocks_data), do: {:retry, blocks_data}
defp run_blocks(
%Blocks{transactions_params: transactions_params},
%Blocks{transactions_params: transactions_params, blocks_params: blocks_params},
blocks_data
) do
found_blocks_map =
blocks_with_transactions_map =
transactions_params
|> Enum.group_by(&Map.fetch!(&1, :block_hash))
|> Map.new(fn {block_hash, trans_lst} -> {block_hash, Enum.count(trans_lst)} end)
found_blocks_map =
blocks_params
|> Map.new(&{Map.fetch!(&1, :hash), 0})
|> Map.merge(blocks_with_transactions_map)
{found_blocks_data, missing_blocks_data} =
Enum.split_with(blocks_data, fn {block, _trans_num} ->
Map.has_key?(found_blocks_map, to_string(block.hash))

Loading…
Cancel
Save