From 9a451ba950ddea12f87ccf6bacb2e1a6345c1902 Mon Sep 17 00:00:00 2001 From: Vamsi Krishna B Date: Wed, 18 Aug 2021 16:57:10 +0530 Subject: [PATCH] Code cleanup --- assets/static/favicon.ico | Bin 15406 -> 15406 bytes .../metrics/mempool_info_warmer.ex | 1 - .../controllers/page_controller.ex | 4 +-- .../controllers/search_controller.ex | 29 +++++++++--------- .../live/block_count_live.ex | 2 ++ .../live/blockchain_size_live.ex | 2 ++ .../live/difficulty_live.ex | 2 ++ .../live/mempool_info_live.ex | 2 ++ .../live/networksolps_live.ex | 2 ++ lib/zcash_explorer_web/live/nodes_live.ex | 6 ++-- lib/zcash_explorer_web/live/price_live.ex | 4 ++- .../live/raw_mempool_live.ex | 8 +++-- .../live/recent_blocks_live.ex | 16 +++++----- .../live/recent_transactions_live.ex | 2 ++ lib/zcash_explorer_web/live/vk_live.ex | 15 ++++----- .../templates/address/address.html.eex | 8 +---- .../templates/block/basic_block.html.eex | 4 +-- lib/zcash_explorer_web/views/block_view.ex | 15 ++------- .../views/transaction_view.ex | 10 ------ 19 files changed, 60 insertions(+), 72 deletions(-) diff --git a/assets/static/favicon.ico b/assets/static/favicon.ico index 8061c05f08a85254e3ffc3ce8d8983102fe782de..873971e81f7df4d25df726abb78a70f387a8aa7d 100644 GIT binary patch literal 15406 zcmeI33zS_|d4TT-SW2lugi>RKVUo<_a_8QA-e!Rkp)F7atTYP6x?ow6s>LdZ6lHO( z$P$)V0TUky2@n$K%_Ng~PcoUz?k+Lv^2!xPFNy_We?>}?*$(}RkJ|;s} zt&6+XnRCv5{QLj^{lE8_Sga~`RP2NkV%)1^S05dVxv^NRx_bP*{=Ko-Qrgn#LVs;6 zHga+-R?irwFk`%(TgAVhTGlaxw(aIz_p$-U`SgHo8`&60l=&^Io_}n=gjdA}R= zyw`_3Z^w}9?i_X9H-}yKx4`;JX8wGzo&0O@yi-_j3-h-3+4dLO8ylf){MVB3PTAp$C}H4Z7~t z@-Dv-%UUt!d2jib>*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d&+>&3dqZ@_q9EO6F$c?NxrI ld`bVa#(d^n$)DnR6C=&t4CUdi~Y;NDIf%m)y{tXTPha~_2 diff --git a/lib/zcash_explorer/metrics/mempool_info_warmer.ex b/lib/zcash_explorer/metrics/mempool_info_warmer.ex index 7caaba9..125052a 100644 --- a/lib/zcash_explorer/metrics/mempool_info_warmer.ex +++ b/lib/zcash_explorer/metrics/mempool_info_warmer.ex @@ -1,5 +1,4 @@ defmodule ZcashExplorer.Metrics.MempoolInfoWarmer do - alias ZcashExplorer.Metrics.MetricsService use Cachex.Warmer @doc """ diff --git a/lib/zcash_explorer_web/controllers/page_controller.ex b/lib/zcash_explorer_web/controllers/page_controller.ex index 15f0468..d0ae5ff 100644 --- a/lib/zcash_explorer_web/controllers/page_controller.ex +++ b/lib/zcash_explorer_web/controllers/page_controller.ex @@ -1,6 +1,5 @@ defmodule ZcashExplorerWeb.PageController do use ZcashExplorerWeb, :controller - alias Phoenix.PubSub def index(conn, _params) do render(conn, "index.html", page_title: "Zcash Explorer - Search the Zcash Blockchain") @@ -99,7 +98,6 @@ defmodule ZcashExplorerWeb.PageController do end def do_import_vk(conn, params) do - height = params["scan-height"] vkey = params["vkey"] @@ -125,7 +123,7 @@ defmodule ZcashExplorerWeb.PageController do ]) container_id = elem(cmd, 0) |> String.trim_trailing("\n") |> String.slice(0, 12) - task = Task.start(fn -> MuonTrap.cmd("docker", ["start", "-a", "-i", container_id]) end) + Task.start(fn -> MuonTrap.cmd("docker", ["start", "-a", "-i", container_id]) end) render(conn, "vk_txs.html", csrf_token: get_csrf_token(), diff --git a/lib/zcash_explorer_web/controllers/search_controller.ex b/lib/zcash_explorer_web/controllers/search_controller.ex index a3d4147..612ceff 100644 --- a/lib/zcash_explorer_web/controllers/search_controller.ex +++ b/lib/zcash_explorer_web/controllers/search_controller.ex @@ -10,10 +10,10 @@ defmodule ZcashExplorerWeb.SearchController do # If zcashd responds that a resource is valid, we redirect the user # to the appropriate resource view or redirect them to an error view. tasks = [ - block_resp = Task.async(fn -> Zcashex.getblock(qs, 0) end), - tx_resp = Task.async(fn -> Zcashex.getrawtransaction(qs, 0) end), - tadd_resp = Task.async(fn -> Zcashex.validateaddress(qs) end), - zadd_resp = Task.async(fn -> Zcashex.z_validateaddress(qs) end) + Task.async(fn -> Zcashex.getblock(qs, 0) end), + Task.async(fn -> Zcashex.getrawtransaction(qs, 0) end), + Task.async(fn -> Zcashex.validateaddress(qs) end), + Task.async(fn -> Zcashex.z_validateaddress(qs) end) ] run = Task.yield_many(tasks, 5000) @@ -24,6 +24,7 @@ defmodule ZcashExplorerWeb.SearchController do res || Task.shutdown(task, :brutal_kill) end) + # order in which the tasks are above defined matters {:ok, block_resp} = Enum.at(results, 0) {:ok, tx_resp} = Enum.at(results, 1) {:ok, tadd_resp} = Enum.at(results, 2) @@ -50,23 +51,23 @@ defmodule ZcashExplorerWeb.SearchController do end end - def is_valid_block?({:ok, hex}) do - true - end - - def is_valid_block?({:error, reason}) do - false - end - def is_valid_block?({:ok, {:error, "Block not found"}}) do false end - def is_valid_tx?({:ok, hex}) do + def is_valid_block?({:ok, _hex}) do true end - def is_valid_tx?({:error, reason}) do + def is_valid_block?({:error, _reason}) do + false + end + + def is_valid_tx?({:ok, _hex}) do + true + end + + def is_valid_tx?({:error, _reason}) do false end diff --git a/lib/zcash_explorer_web/live/block_count_live.ex b/lib/zcash_explorer_web/live/block_count_live.ex index 36d4122..4034c64 100644 --- a/lib/zcash_explorer_web/live/block_count_live.ex +++ b/lib/zcash_explorer_web/live/block_count_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.BlockCountLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""

@@ -22,6 +23,7 @@ defmodule ZcashExplorerWeb.BlockCountLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 15000) {:ok, info} = Cachex.get(:app_cache, "metrics") diff --git a/lib/zcash_explorer_web/live/blockchain_size_live.ex b/lib/zcash_explorer_web/live/blockchain_size_live.ex index 989285b..0c16666 100644 --- a/lib/zcash_explorer_web/live/blockchain_size_live.ex +++ b/lib/zcash_explorer_web/live/blockchain_size_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.BlockChainSizeLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""

@@ -22,6 +23,7 @@ defmodule ZcashExplorerWeb.BlockChainSizeLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 15000) {:ok, info} = Cachex.get(:app_cache, "metrics") diff --git a/lib/zcash_explorer_web/live/difficulty_live.ex b/lib/zcash_explorer_web/live/difficulty_live.ex index de58b4e..efbad46 100644 --- a/lib/zcash_explorer_web/live/difficulty_live.ex +++ b/lib/zcash_explorer_web/live/difficulty_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.DifficultyLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""

@@ -22,6 +23,7 @@ defmodule ZcashExplorerWeb.DifficultyLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 5000) {:ok, info} = Cachex.get(:app_cache, "metrics") diff --git a/lib/zcash_explorer_web/live/mempool_info_live.ex b/lib/zcash_explorer_web/live/mempool_info_live.ex index d64d53b..0977783 100644 --- a/lib/zcash_explorer_web/live/mempool_info_live.ex +++ b/lib/zcash_explorer_web/live/mempool_info_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.MempoolInfoLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""

@@ -22,6 +23,7 @@ defmodule ZcashExplorerWeb.MempoolInfoLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 1000) {:ok, info} = Cachex.get(:app_cache, "mempool_info") diff --git a/lib/zcash_explorer_web/live/networksolps_live.ex b/lib/zcash_explorer_web/live/networksolps_live.ex index 4b9f1d7..be78158 100644 --- a/lib/zcash_explorer_web/live/networksolps_live.ex +++ b/lib/zcash_explorer_web/live/networksolps_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.NetworkSolpsLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""

@@ -22,6 +23,7 @@ defmodule ZcashExplorerWeb.NetworkSolpsLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 30000) {:ok, info} = Cachex.get(:app_cache, "networksolps") diff --git a/lib/zcash_explorer_web/live/nodes_live.ex b/lib/zcash_explorer_web/live/nodes_live.ex index 93be40b..e3eeb28 100644 --- a/lib/zcash_explorer_web/live/nodes_live.ex +++ b/lib/zcash_explorer_web/live/nodes_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.NodesLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""

@@ -17,14 +18,14 @@ defmodule ZcashExplorerWeb.NodesLive do <%= node["addr"] %> - + <%= node["subver"] %> <%= node["synced_blocks"] %> - + <% end %> @@ -45,6 +46,7 @@ defmodule ZcashExplorerWeb.NodesLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 5000) {:ok, zcash_nodes} = Cachex.get(:app_cache, "zcash_nodes") diff --git a/lib/zcash_explorer_web/live/price_live.ex b/lib/zcash_explorer_web/live/price_live.ex index 860f706..7bd6cb8 100644 --- a/lib/zcash_explorer_web/live/price_live.ex +++ b/lib/zcash_explorer_web/live/price_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.PriceLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""
@@ -26,7 +27,7 @@ defmodule ZcashExplorerWeb.PriceLive do Decreased by @@ -58,6 +59,7 @@ defmodule ZcashExplorerWeb.PriceLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 3000) {:ok, price} = Cachex.get(:app_cache, "price") diff --git a/lib/zcash_explorer_web/live/raw_mempool_live.ex b/lib/zcash_explorer_web/live/raw_mempool_live.ex index b112a99..87d1fa8 100644 --- a/lib/zcash_explorer_web/live/raw_mempool_live.ex +++ b/lib/zcash_explorer_web/live/raw_mempool_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.RawMempoolLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""
@@ -21,7 +22,7 @@ defmodule ZcashExplorerWeb.RawMempoolLive do <%= tx["txid"] %> - + <%= tx["info"]["height"] %> @@ -30,11 +31,11 @@ defmodule ZcashExplorerWeb.RawMempoolLive do <%= ZcashExplorerWeb.TransactionView.format_zec(tx["info"]["fee"]) %> - + <%= tx["info"]["size"] %> - + <% end %> @@ -55,6 +56,7 @@ defmodule ZcashExplorerWeb.RawMempoolLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 5000) {:ok, mempool} = Cachex.get(:app_cache, "raw_mempool") diff --git a/lib/zcash_explorer_web/live/recent_blocks_live.ex b/lib/zcash_explorer_web/live/recent_blocks_live.ex index 86c868b..9f2f22e 100644 --- a/lib/zcash_explorer_web/live/recent_blocks_live.ex +++ b/lib/zcash_explorer_web/live/recent_blocks_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.RecentBlocksLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""
@@ -27,21 +28,21 @@ defmodule ZcashExplorerWeb.RecentBlocksLive do <%= block["hash"] %> - + <%= block["time"] %> - + <%= block["tx_count"] %> - + <%= block["size"] %> - + <%= block["output_total"] %> - - - + + + <% end %> @@ -61,6 +62,7 @@ defmodule ZcashExplorerWeb.RecentBlocksLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 1000) {:ok, info} = Cachex.get(:app_cache, "block_cache") diff --git a/lib/zcash_explorer_web/live/recent_transactions_live.ex b/lib/zcash_explorer_web/live/recent_transactions_live.ex index fa460cf..0e5a990 100644 --- a/lib/zcash_explorer_web/live/recent_transactions_live.ex +++ b/lib/zcash_explorer_web/live/recent_transactions_live.ex @@ -1,6 +1,7 @@ defmodule ZcashExplorerWeb.RecentTransactionsLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L"""
@@ -86,6 +87,7 @@ defmodule ZcashExplorerWeb.RecentTransactionsLive do end end + @impl true def handle_info(:update, socket) do Process.send_after(self(), :update, 1000) {:ok, info} = Cachex.get(:app_cache, "transaction_cache") diff --git a/lib/zcash_explorer_web/live/vk_live.ex b/lib/zcash_explorer_web/live/vk_live.ex index 2d238c3..16ca5eb 100644 --- a/lib/zcash_explorer_web/live/vk_live.ex +++ b/lib/zcash_explorer_web/live/vk_live.ex @@ -1,13 +1,12 @@ defmodule ZcashExplorerWeb.VkLive do use Phoenix.LiveView + @impl true def render(assigns) do ~L""" -
<%= @message["message"] %>
- <%= if length(@message["txs"]) > 0 do %>
@@ -21,7 +20,6 @@ defmodule ZcashExplorerWeb.VkLive do - <%= for tx <- @message["txs"] do %> + - + + <% end %> -
@@ -37,13 +35,12 @@ defmodule ZcashExplorerWeb.VkLive do <%= ZcashExplorerWeb.BlockView.mined_time_rel(tx["datetime"]) %> - <%= tx["memo"] %> -
<% end %> @@ -51,11 +48,11 @@ defmodule ZcashExplorerWeb.VkLive do end @impl true - def mount(params, session, socket) do + def mount(_params, session, socket) do if connected?(socket) do container_id = Map.get(session, "container_id") Process.send_after(self(), :update, 3000) - subscribed = Phoenix.PubSub.subscribe(ZcashExplorer.PubSub, "VK:" <> "#{container_id}") + Phoenix.PubSub.subscribe(ZcashExplorer.PubSub, "VK:" <> "#{container_id}") end {:ok, diff --git a/lib/zcash_explorer_web/templates/address/address.html.eex b/lib/zcash_explorer_web/templates/address/address.html.eex index 6adb817..923385a 100644 --- a/lib/zcash_explorer_web/templates/address/address.html.eex +++ b/lib/zcash_explorer_web/templates/address/address.html.eex @@ -91,11 +91,7 @@ - <%= end %> - - - - + <% end %> @@ -106,8 +102,6 @@
- -

Transactions from block diff --git a/lib/zcash_explorer_web/templates/block/basic_block.html.eex b/lib/zcash_explorer_web/templates/block/basic_block.html.eex index 6a1f674..8ce0b40 100644 --- a/lib/zcash_explorer_web/templates/block/basic_block.html.eex +++ b/lib/zcash_explorer_web/templates/block/basic_block.html.eex @@ -54,7 +54,7 @@ <%= if @block_data["previousblockhash"] do %> <%= @block_data["height"] - 1 %> - <%= end %> + <% end %>

@@ -65,7 +65,7 @@
<%= if @block_data["nextblockhash"] do %> <%= @block_data["height"] + 1 %> - <%= end %> + <% end %>
diff --git a/lib/zcash_explorer_web/views/block_view.ex b/lib/zcash_explorer_web/views/block_view.ex index a9bcee3..e19c993 100644 --- a/lib/zcash_explorer_web/views/block_view.ex +++ b/lib/zcash_explorer_web/views/block_view.ex @@ -16,7 +16,7 @@ defmodule ZcashExplorerWeb.BlockView do end def mined_time_rel(timestamp) do - rel = timestamp |> Timex.from_unix() |> Timex.format!("{relative}", :relative) + timestamp |> Timex.from_unix() |> Timex.format!("{relative}", :relative) end def transaction_count(txs) do @@ -40,7 +40,7 @@ defmodule ZcashExplorerWeb.BlockView do case Map.fetch(first_tx, :coinbase) do {:ok, nil} -> false - {:ok, value} -> true + {:ok, _value} -> true {:error, _reason} -> false end end @@ -168,15 +168,4 @@ defmodule ZcashExplorerWeb.BlockView do end end - # TODO : complete later - def block_subsidy(block_subsidy) do - case block_subsidy do - %{"founders" => founders, "miner" => miner} when is_map(block_subsidy) -> - %{"founder" => founders, "miner" => miner} - - %{"founders" => 0.0, "fundingstreams" => fundingstreams, "miner" => miner} - when is_map(block_subsidy) -> - %{} - end - end end diff --git a/lib/zcash_explorer_web/views/transaction_view.ex b/lib/zcash_explorer_web/views/transaction_view.ex index e162b30..74ee3e7 100644 --- a/lib/zcash_explorer_web/views/transaction_view.ex +++ b/lib/zcash_explorer_web/views/transaction_view.ex @@ -33,7 +33,6 @@ defmodule ZcashExplorerWeb.TransactionView do length(tx.vout) == 0 and length(tx.vShieldedOutput) > 0 and tx.valueBalance < 0.0 do - IO.inspect("38") "Transferred to shielded pool" end @@ -41,14 +40,12 @@ defmodule ZcashExplorerWeb.TransactionView do # 1 def get_shielded_pool_label(tx) when tx.vjoinsplit != nil and length(tx.vjoinsplit) > 0 and length(tx.vin) > 0 do - IO.inspect("47") "Transferred to shielded pool" end # handle when and vjoinsplit is present and vin == 0 .. def get_shielded_pool_label(tx) when tx.vjoinsplit != nil and length(tx.vjoinsplit) > 0 and length(tx.vin) == 0 do - IO.inspect("") "Transferred from shielded pool" end @@ -59,14 +56,12 @@ defmodule ZcashExplorerWeb.TransactionView do length(tx.vin) > 0 and length(tx.vShieldedOutput) > 0 and tx.valueBalance < 0.0 do - IO.inspect("68") "Transferred to shielded pool" end # handle public tx def get_shielded_pool_label(tx) when tx.vjoinsplit != nil and length(tx.vjoinsplit) == 0 and length(tx.vin) > 0 do - IO.inspect("76") "Transferred from/to shielded pool" end @@ -74,7 +69,6 @@ defmodule ZcashExplorerWeb.TransactionView do def get_shielded_pool_label(tx) when tx.vjoinsplit != nil and length(tx.vjoinsplit) == 0 and length(tx.vin) == 0 and length(tx.vout) > 0 and tx.valueBalance > 0 do - IO.inspect("85") "Transferred from shielded pool" end @@ -82,7 +76,6 @@ defmodule ZcashExplorerWeb.TransactionView do def get_shielded_pool_label(tx) when tx.vjoinsplit != nil and length(tx.vjoinsplit) == 0 and length(tx.vin) == 0 and length(tx.vout) == 0 and tx.valueBalance > 0 do - IO.inspect("93") "Transferred from shielded pool" end @@ -146,8 +139,6 @@ defmodule ZcashExplorerWeb.TransactionView do length(tx.vjoinsplit) > 0 and length(tx.vin) == 0 and length(tx.vout) > 0 do - IO.inspect(177) - val = tx |> Map.get(:vjoinsplit) @@ -177,7 +168,6 @@ defmodule ZcashExplorerWeb.TransactionView do end def tx_in_total(tx) when is_map(tx) do - IO.inspect(tx.vin) tx.vin |> Enum.reduce(0, fn x, acc -> x.value + acc end) end