Fix unexpected messages in CoinBalanceOnDemand

pull/5948/head
Qwerty5Uiop 2 years ago
parent 155afbb8f1
commit 3d0ef1efc9
  1. 14
      apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex

@ -64,10 +64,12 @@ defmodule Indexer.Fetcher.CoinBalanceOnDemand do
GenServer.start_link(__MODULE__, json_rpc_named_arguments, server_opts) GenServer.start_link(__MODULE__, json_rpc_named_arguments, server_opts)
end end
@impl true
def init(json_rpc_named_arguments) do def init(json_rpc_named_arguments) do
{:ok, %{json_rpc_named_arguments: json_rpc_named_arguments}} {:ok, %{json_rpc_named_arguments: json_rpc_named_arguments}}
end end
@impl true
def handle_cast({:fetch_and_update, block_number, address}, state) do def handle_cast({:fetch_and_update, block_number, address}, state) do
result = fetch_and_update(block_number, address, state.json_rpc_named_arguments) result = fetch_and_update(block_number, address, state.json_rpc_named_arguments)
@ -78,18 +80,30 @@ defmodule Indexer.Fetcher.CoinBalanceOnDemand do
{:noreply, state} {:noreply, state}
end end
@impl true
def handle_cast({:fetch_and_import, block_number, address}, state) do def handle_cast({:fetch_and_import, block_number, address}, state) do
fetch_and_import(block_number, address, state.json_rpc_named_arguments) fetch_and_import(block_number, address, state.json_rpc_named_arguments)
{:noreply, state} {:noreply, state}
end end
@impl true
def handle_cast({:fetch_and_import_daily_balances, block_number, address}, state) do def handle_cast({:fetch_and_import_daily_balances, block_number, address}, state) do
fetch_and_import_daily_balances(block_number, address, state.json_rpc_named_arguments) fetch_and_import_daily_balances(block_number, address, state.json_rpc_named_arguments)
{:noreply, state} {:noreply, state}
end end
@impl true
def handle_info({:DOWN, _, :process, _, _}, state) do
{:noreply, state}
end
@impl true
def handle_info({_ref, _}, state) do
{:noreply, state}
end
## Implementation ## Implementation
defp do_trigger_fetch(%Address{fetched_coin_balance_block_number: nil} = address, latest_block_number, _) do defp do_trigger_fetch(%Address{fetched_coin_balance_block_number: nil} = address, latest_block_number, _) do

Loading…
Cancel
Save