set block_hash in logs params

pull/2895/head
Ayrat Badykov 5 years ago
parent a2a32115fd
commit 1f108d7673
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 1
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/log.ex
  2. 2
      apps/explorer/lib/explorer/chain/import/runner/blocks.ex
  3. 2
      apps/explorer/lib/explorer/chain/import/runner/logs.ex
  4. 14
      apps/explorer/lib/explorer/chain/log.ex

@ -98,6 +98,7 @@ defmodule EthereumJSONRPC.Log do
block_number: block_number,
block_hash: block_hash,
data: data,
block_hash: block_hash,
index: index,
transaction_hash: transaction_hash
}

@ -9,7 +9,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do
alias Ecto.{Changeset, Multi, Repo}
alias Explorer.Chain.{Address, Block, Import, Log, PendingBlockOperation, Transaction}
alias Explorer.Chain.{Address, Block, Import, PendingBlockOperation, Transaction}
alias Explorer.Chain.Block.Reward
alias Explorer.Chain.Import.Runner
alias Explorer.Chain.Import.Runner.Address.CurrentTokenBalances

@ -65,7 +65,7 @@ defmodule Explorer.Chain.Import.Runner.Logs do
Import.insert_changes_list(
repo,
ordered_changes_list,
conflict_target: [:transaction_hash, :index],
conflict_target: [:transaction_hash, :index, :block_hash],
on_conflict: on_conflict,
for: Log,
returning: true,

@ -6,14 +6,15 @@ defmodule Explorer.Chain.Log do
require Logger
alias ABI.{Event, FunctionSelector}
alias Explorer.Chain.{Address, ContractMethod, Data, Hash, Transaction}
alias Explorer.Chain.{Address, Block, ContractMethod, Data, Hash, Transaction}
alias Explorer.Repo
@required_attrs ~w(address_hash data index transaction_hash)a
@required_attrs ~w(address_hash data block_hash index transaction_hash)a
@optional_attrs ~w(first_topic second_topic third_topic fourth_topic type)a
@typedoc """
* `address` - address of contract that generate the event
* `block_hash` - hash of the block
* `address_hash` - foreign key for `address`
* `data` - non-indexed log parameters.
* `first_topic` - `topics[0]`
@ -28,6 +29,7 @@ defmodule Explorer.Chain.Log do
@type t :: %__MODULE__{
address: %Ecto.Association.NotLoaded{} | Address.t(),
address_hash: Hash.Address.t(),
block_hash: Hash.Full.t(),
data: Data.t(),
first_topic: String.t(),
second_topic: String.t(),
@ -59,6 +61,14 @@ defmodule Explorer.Chain.Log do
references: :hash,
type: Hash.Full
)
belongs_to(:block, Block,
foreign_key: :block_hash,
primary_key: true,
references: :hash,
type: Hash.Full
)
end
@doc """

Loading…
Cancel
Save