|
|
@ -358,22 +358,31 @@ defmodule Explorer.Chain do |
|
|
|
base_query = |
|
|
|
base_query = |
|
|
|
from(log in Log, |
|
|
|
from(log in Log, |
|
|
|
inner_join: transaction in Transaction, |
|
|
|
inner_join: transaction in Transaction, |
|
|
|
on: |
|
|
|
on: transaction.hash == log.transaction_hash, |
|
|
|
transaction.block_hash == log.block_hash and transaction.block_number == log.block_number and |
|
|
|
order_by: [desc: log.block_number, desc: log.index], |
|
|
|
transaction.hash == log.transaction_hash, |
|
|
|
|
|
|
|
order_by: [desc: transaction.block_number, desc: transaction.index], |
|
|
|
|
|
|
|
preload: [:transaction, transaction: [to_address: :smart_contract]], |
|
|
|
|
|
|
|
where: transaction.block_number < ^block_number, |
|
|
|
where: transaction.block_number < ^block_number, |
|
|
|
or_where: transaction.block_number == ^block_number and transaction.index > ^transaction_index, |
|
|
|
or_where: transaction.block_number == ^block_number and transaction.index > ^transaction_index, |
|
|
|
or_where: |
|
|
|
or_where: |
|
|
|
transaction.block_number == ^block_number and transaction.index == ^transaction_index and |
|
|
|
transaction.block_number == ^block_number and transaction.index == ^transaction_index and |
|
|
|
log.index > ^log_index, |
|
|
|
log.index > ^log_index, |
|
|
|
where: log.address_hash == ^address_hash and log.block_hash == transaction.block_hash, |
|
|
|
where: log.address_hash == ^address_hash, |
|
|
|
limit: ^paging_options.page_size, |
|
|
|
limit: ^paging_options.page_size, |
|
|
|
select: log |
|
|
|
select: log |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
base_query |
|
|
|
wrapped_query = |
|
|
|
|
|
|
|
from( |
|
|
|
|
|
|
|
log in subquery(base_query), |
|
|
|
|
|
|
|
inner_join: transaction in Transaction, |
|
|
|
|
|
|
|
preload: [:transaction, transaction: [to_address: :smart_contract]], |
|
|
|
|
|
|
|
where: |
|
|
|
|
|
|
|
log.block_hash == transaction.block_hash and |
|
|
|
|
|
|
|
log.block_number == transaction.block_number and |
|
|
|
|
|
|
|
log.transaction_hash == transaction.hash, |
|
|
|
|
|
|
|
select: log |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapped_query |
|
|
|
|> filter_topic(options) |
|
|
|
|> filter_topic(options) |
|
|
|
|> Repo.all() |
|
|
|
|> Repo.all() |
|
|
|
|> Enum.take(paging_options.page_size) |
|
|
|
|> Enum.take(paging_options.page_size) |
|
|
|