Skip to content

Commit

Permalink
Create recommended index on tx table.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkachowski committed Feb 7, 2024
1 parent 3e27da0 commit ec5583c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ defmodule BlockScoutWeb.TransactionView do
token = Transaction.get_fee_token_name(transaction)

case token do
{:ok, address} -> address
{:ok, address} ->
address

{:error, :not_found} ->
Logger.info("Found unknown gas token at #{inspect(gch)}")
ChainToken.set_uncatalogued_token(transaction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ defmodule Explorer.Chain.Import.Runner.Address.TokenBalances do
{:unsafe_fragment, ~s<(address_hash, token_contract_address_hash, COALESCE(token_id, -1), block_number)>},
on_conflict: on_conflict,
for: TokenBalance,
returning: false
returning: false,
timeout: timeout,
timestamps: timestamps
)
Expand Down
1 change: 1 addition & 0 deletions apps/explorer/lib/explorer/chain/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ defmodule Explorer.Chain.Token do
end

def set_uncatalogued_token(%{gas_currency_hash: nil}), do: :ok

def set_uncatalogued_token(%{gas_currency_hash: address}) do
%Token{}
|> changeset(%{contract_address_hash: address, type: "ERC-20"})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule Explorer.Repo.Local.Migrations.RecommendedTxIndex do
use Ecto.Migration

def change do
create_if_not_exists(
index(
:transactions,
[
:block_hash,
:hash
],
name: "transactions_block_hash_hash",
concurrently: true
)
)
end
end

0 comments on commit ec5583c

Please sign in to comment.