Merge branch 'master' into ab-exclude-decompiled-contract-from-encoding

pull/1692/head
Ayrat Badykov 6 years ago committed by GitHub
commit f3ab7fc4de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/contract.ex
  3. 12
      apps/explorer/lib/explorer/chain.ex
  4. 2
      apps/explorer/lib/explorer/chain/transaction_count_cache.ex
  5. 2
      apps/explorer/test/explorer/chain/transaction_count_cache_test.exs

@ -8,6 +8,7 @@
### Fixes
- [#1669](https://github.com/poanetwork/blockscout/pull/1669) - do not fail if multiple matching tokens are found
- [#1688](https://github.com/poanetwork/blockscout/pull/1688) - do not fail if failure reason is atom
### Chore

@ -46,6 +46,7 @@ defmodule EthereumJSONRPC.Contract do
|> case do
{:ok, responses} -> responses
{:error, {:bad_gateway, _request_url}} -> raise "Bad gateway"
{:error, reason} when is_atom(reason) -> raise Atom.to_string(reason)
{:error, error} -> raise error
end
|> Enum.into(%{}, &{&1.id, &1})

@ -20,6 +20,7 @@ defmodule Explorer.Chain do
import EthereumJSONRPC, only: [integer_to_quantity: 1]
alias Ecto.Adapters.SQL
alias Ecto.{Changeset, Multi}
alias Explorer.Chain.{
@ -1898,7 +1899,16 @@ defmodule Explorer.Chain do
"""
@spec transaction_estimated_count() :: non_neg_integer()
def transaction_estimated_count do
TransactionCountCache.value()
cached_value = TransactionCountCache.value()
if is_nil(cached_value) do
%Postgrex.Result{rows: [[rows]]} =
SQL.query!(Repo, "SELECT reltuples::BIGINT AS estimate FROM pg_class WHERE relname='transactions'")
rows
else
cached_value
end
end
@doc """

@ -12,7 +12,7 @@ defmodule Explorer.Chain.TransactionCountCache do
# 2 hours
@cache_period 1_000 * 60 * 60 * 2
@default_value 0
@default_value nil
@key "count"
@name __MODULE__

@ -8,7 +8,7 @@ defmodule Explorer.Chain.TransactionCountCacheTest do
result = TransactionCountCache.value(TestCache)
assert result == 0
assert is_nil(result)
end
test "updates cache if initial value is zero" do

Loading…
Cancel
Save