Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/lib/explorer/block_transaction.ex

28 lines
830 B

defmodule Explorer.BlockTransaction do
@moduledoc false
alias Explorer.BlockTransaction
import Ecto.Changeset
use Ecto.Schema
@timestamps_opts [type: Timex.Ecto.DateTime,
autogenerate: {Timex.Ecto.DateTime, :autogenerate, []}]
@primary_key false
schema "block_transactions" do
belongs_to :block, Explorer.Block
belongs_to :transaction, Explorer.Transaction, primary_key: true
timestamps()
end
@required_attrs ~w(block_id transaction_id)a
def changeset(%BlockTransaction{} = block_transaction, attrs \\ %{}) do
block_transaction
|> cast(attrs, @required_attrs)
|> validate_required(@required_attrs)
|> cast_assoc(:block)
|> cast_assoc(:transaction)
|> unique_constraint(:transaction_id,
name: :block_transactions_transaction_id_index)
end
end