forked from blockscout/blockscout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: OP modules improvements (blockscout#11073)
* Add new envs for OP stack * Fix updating logs filter in OP Deposits fetcher * Add fallback envs for OP * Add socket notifier for OP batches * Update common-blockscout.env * Set infinity timeout for select db queries * Support transactions without `to` field * Add some docs * mix format * Restore OP fetcher after reorg and restart * Add specs and docs * Fix spelling * Refactoring and hardcode INDEXER_BEACON_BLOB_FETCHER_* envs * mix format * Update spelling * Small fix for Indexer.Fetcher.Optimism.Deposit * Rewrite Indexer.Fetcher.Optimism.Deposit * Update common-blockscout.env * Add todo comments for deprecated socket topic * Fix for the new websocket channel * Add todo comment --------- Co-authored-by: POA <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,020 additions
and
703 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
apps/block_scout_web/lib/block_scout_web/channels/optimism_channel.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule BlockScoutWeb.OptimismChannel do | ||
@moduledoc """ | ||
Establishes pub/sub channel for live updates of OP related events. | ||
""" | ||
use BlockScoutWeb, :channel | ||
|
||
def join("optimism:new_batch", _params, socket) do | ||
{:ok, %{}, socket} | ||
end | ||
|
||
def join("optimism:new_deposits", _params, socket) do | ||
{:ok, %{}, socket} | ||
end | ||
|
||
# todo: the `optimism_deposits:new_deposits` socket topic is for backward compatibility | ||
# for the frontend and should be removed after the frontend starts to use the `optimism:new_deposits` | ||
def join("optimism_deposits:new_deposits", _params, socket) do | ||
{:ok, %{}, socket} | ||
end | ||
end |
22 changes: 0 additions & 22 deletions
22
apps/block_scout_web/lib/block_scout_web/channels/optimism_deposit_channel.ex
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
apps/block_scout_web/lib/block_scout_web/notifiers/optimism.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
defmodule BlockScoutWeb.Notifiers.Optimism do | ||
@moduledoc """ | ||
Module to handle and broadcast OP related events. | ||
""" | ||
|
||
alias BlockScoutWeb.Endpoint | ||
|
||
require Logger | ||
|
||
def handle_event({:chain_event, :new_optimism_batches, :realtime, batches}) do | ||
batches | ||
|> Enum.sort_by(& &1.internal_id, :asc) | ||
|> Enum.each(fn batch -> | ||
Endpoint.broadcast("optimism:new_batch", "new_optimism_batch", %{ | ||
batch: batch | ||
}) | ||
end) | ||
end | ||
|
||
def handle_event({:chain_event, :new_optimism_deposits, :realtime, deposits}) do | ||
deposits_count = Enum.count(deposits) | ||
|
||
if deposits_count > 0 do | ||
Endpoint.broadcast("optimism:new_deposits", "new_optimism_deposits", %{ | ||
deposits: deposits_count | ||
}) | ||
|
||
# todo: the `optimism_deposits:new_deposits` socket topic is for backward compatibility | ||
# for the frontend and should be removed after the frontend starts to use the `optimism:new_deposits` | ||
Endpoint.broadcast("optimism_deposits:new_deposits", "deposits", %{ | ||
deposits: deposits_count | ||
}) | ||
end | ||
end | ||
|
||
def handle_event(event) do | ||
Logger.warning("Unknown broadcasted event #{inspect(event)}.") | ||
nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.