Merge pull request #9018 from blockscout/ap-smart-contract-event-handler

Add SmartContractRealtimeEventHandler
pull/9015/head
Victor Baranov 11 months ago committed by GitHub
commit bf9a10bcd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 3
      apps/block_scout_web/lib/block_scout_web/application.ex
  3. 3
      apps/block_scout_web/lib/block_scout_web/realtime_event_handler.ex
  4. 28
      apps/block_scout_web/lib/block_scout_web/smart_contract_realtime_event_handler.ex

@ -4,6 +4,7 @@
### Features ### Features
- [#9018](https://github.com/blockscout/blockscout/pull/9018) - Add SmartContractRealtimeEventHandler
- [#8997](https://github.com/blockscout/blockscout/pull/8997) - Isolate throttable error count by request method - [#8997](https://github.com/blockscout/blockscout/pull/8997) - Isolate throttable error count by request method
- [#8975](https://github.com/blockscout/blockscout/pull/8975) - Add EIP-4844 compatibility (not full support yet) - [#8975](https://github.com/blockscout/blockscout/pull/8975) - Add EIP-4844 compatibility (not full support yet)
- [#8972](https://github.com/blockscout/blockscout/pull/8972) - BENS integration - [#8972](https://github.com/blockscout/blockscout/pull/8972) - BENS integration

@ -8,7 +8,7 @@ defmodule BlockScoutWeb.Application do
alias BlockScoutWeb.API.APILogger alias BlockScoutWeb.API.APILogger
alias BlockScoutWeb.Counters.{BlocksIndexedCounter, InternalTransactionsIndexedCounter} alias BlockScoutWeb.Counters.{BlocksIndexedCounter, InternalTransactionsIndexedCounter}
alias BlockScoutWeb.{Endpoint, Prometheus} alias BlockScoutWeb.{Endpoint, Prometheus}
alias BlockScoutWeb.{MainPageRealtimeEventHandler, RealtimeEventHandler} alias BlockScoutWeb.{MainPageRealtimeEventHandler, RealtimeEventHandler, SmartContractRealtimeEventHandler}
def start(_type, _args) do def start(_type, _args) do
import Supervisor import Supervisor
@ -36,6 +36,7 @@ defmodule BlockScoutWeb.Application do
{Absinthe.Subscription, Endpoint}, {Absinthe.Subscription, Endpoint},
{MainPageRealtimeEventHandler, name: MainPageRealtimeEventHandler}, {MainPageRealtimeEventHandler, name: MainPageRealtimeEventHandler},
{RealtimeEventHandler, name: RealtimeEventHandler}, {RealtimeEventHandler, name: RealtimeEventHandler},
{SmartContractRealtimeEventHandler, name: SmartContractRealtimeEventHandler},
{BlocksIndexedCounter, name: BlocksIndexedCounter}, {BlocksIndexedCounter, name: BlocksIndexedCounter},
{InternalTransactionsIndexedCounter, name: InternalTransactionsIndexedCounter} {InternalTransactionsIndexedCounter, name: InternalTransactionsIndexedCounter}
] ]

@ -24,11 +24,8 @@ defmodule BlockScoutWeb.RealtimeEventHandler do
Subscriber.to(:address_coin_balances, :on_demand) Subscriber.to(:address_coin_balances, :on_demand)
Subscriber.to(:address_current_token_balances, :on_demand) Subscriber.to(:address_current_token_balances, :on_demand)
Subscriber.to(:address_token_balances, :on_demand) Subscriber.to(:address_token_balances, :on_demand)
Subscriber.to(:contract_verification_result, :on_demand)
Subscriber.to(:token_total_supply, :on_demand) Subscriber.to(:token_total_supply, :on_demand)
Subscriber.to(:changed_bytecode, :on_demand) Subscriber.to(:changed_bytecode, :on_demand)
Subscriber.to(:smart_contract_was_verified, :on_demand)
Subscriber.to(:smart_contract_was_not_verified, :on_demand)
Subscriber.to(:eth_bytecode_db_lookup_started, :on_demand) Subscriber.to(:eth_bytecode_db_lookup_started, :on_demand)
Subscriber.to(:zkevm_confirmed_batches, :realtime) Subscriber.to(:zkevm_confirmed_batches, :realtime)
# Does not come from the indexer # Does not come from the indexer

@ -0,0 +1,28 @@
defmodule BlockScoutWeb.SmartContractRealtimeEventHandler do
@moduledoc """
Subscribing process for smart contract verification related broadcast events from realtime.
"""
use GenServer
alias BlockScoutWeb.Notifier
alias Explorer.Chain.Events.Subscriber
def start_link(_) do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
@impl true
def init([]) do
Subscriber.to(:contract_verification_result, :on_demand)
Subscriber.to(:smart_contract_was_verified, :on_demand)
Subscriber.to(:smart_contract_was_not_verified, :on_demand)
{:ok, []}
end
@impl true
def handle_info(event, state) do
Notifier.handle_event(event)
{:noreply, state}
end
end
Loading…
Cancel
Save