Process review comments

pull/8512/head
Nikita Pozdniakov 1 year ago
parent 6896b092df
commit 4614878507
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 11
      apps/explorer/lib/explorer/chain/address/counters.ex
  2. 10
      apps/explorer/lib/explorer/chain/cache/addresses_tabs_counters.ex

@ -245,7 +245,7 @@ defmodule Explorer.Chain.Address.Counters do
end
end
def address_hash_to_internal_txs_limited_count_query(address_hash) do
defp address_hash_to_internal_txs_limited_count_query(address_hash) do
query_to_address_hash_wrapped =
InternalTransaction
|> InternalTransaction.where_nonpending_block()
@ -570,6 +570,15 @@ defmodule Explorer.Chain.Address.Counters do
end)
end
@doc """
Returns all possible transactions type
"""
@spec txs_types :: list(atom)
def txs_types, do: @txs_types
@doc """
Returns max counter value
"""
@spec counters_limit :: integer()
def counters_limit, do: @counters_limit
end

@ -27,18 +27,22 @@ defmodule Explorer.Chain.Cache.AddressesTabsCounters do
:ok
end
@spec set_task(atom, String.t()) :: true
def set_task(counter_type, address_hash) do
:ets.insert(@cache_name, {task_cache_key(address_hash, counter_type), true})
end
@spec drop_task(atom, String.t()) :: true
def drop_task(counter_type, address_hash) do
:ets.delete(@cache_name, task_cache_key(address_hash, counter_type))
end
@spec get_task(atom, String.t()) :: true | nil
def get_task(counter_type, address_hash) do
address_hash |> task_cache_key(counter_type) |> fetch_from_cache(@cache_name, nil)
end
@spec ignore_txs(atom, String.t()) :: :ignore | :ok
def ignore_txs(:txs, address_hash), do: GenServer.cast(__MODULE__, {:ignore_txs, address_hash})
def ignore_txs(_counter_type, _address_hash), do: :ignore
@ -103,10 +107,10 @@ defmodule Explorer.Chain.Cache.AddressesTabsCounters do
defp is_ignored?({:updated, datetime}), do: is_up_to_date?(datetime, ttl())
defp is_ignored?(_), do: false
def check_staleness(nil), do: nil
def check_staleness({datetime, counter}) when counter > 50, do: {datetime, counter, :limit_value}
defp check_staleness(nil), do: nil
defp check_staleness({datetime, counter}) when counter > 50, do: {datetime, counter, :limit_value}
def check_staleness({datetime, counter}) do
defp check_staleness({datetime, counter}) do
status =
if is_up_to_date?(datetime, ttl()) do
:up_to_date

Loading…
Cancel
Save