From d54021cbfb841dd48507b2e04dde103372ab3dcb Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 17:04:25 +0300 Subject: [PATCH] fix CR issue --- .../lib/ethereum_jsonrpc/rolling_window.ex | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex index 0f83568f33..d761560315 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex @@ -209,18 +209,20 @@ defmodule EthereumJSONRPC.RollingWindow do @doc """ Display the raw contents of all windows for a given key. """ - @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) + @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) || [] def inspect(table, key) do - if :ets.whereis(table) == :undefined do - [] - else - case :ets.lookup(table, key) do - [{_, current_window, windows}] -> - [current_window | windows] - - _ -> - [] - end + case :ets.whereis(table) do + :undefined -> + [] + + tid -> + case :ets.lookup(tid, key) do + [{_, current_window, windows}] -> + [current_window | windows] + + _ -> + [] + end end end end