Merge pull request #9018 from blockscout/ap-smart-contract-event-handler
Add SmartContractRealtimeEventHandlerpull/9015/head
commit
bf9a10bcd9
@ -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…
Reference in new issue