Added zcashd version
This commit is contained in:
parent
00dcecce66
commit
87e6c61d86
|
@ -38,7 +38,8 @@ defmodule ZcashExplorer.Application do
|
|||
warmer(module: ZcashExplorer.Blocks.BlockWarmer, state: {}),
|
||||
warmer(module: ZcashExplorer.Transactions.TransactionWarmer, state: {}),
|
||||
warmer(module: ZcashExplorer.Mempool.MempoolWarmer, state: {}),
|
||||
warmer(module: ZcashExplorer.Nodes.NodeWarmer, state: {})
|
||||
warmer(module: ZcashExplorer.Nodes.NodeWarmer, state: {}),
|
||||
warmer(module: ZcashExplorer.Metrics.InfoWarmer, state: {})
|
||||
]}
|
||||
]
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
defmodule ZcashExplorer.Metrics.InfoWarmer do
|
||||
use Cachex.Warmer
|
||||
|
||||
@doc """
|
||||
Returns the interval for this warmer.
|
||||
"""
|
||||
def interval,
|
||||
do: :timer.seconds(60)
|
||||
|
||||
@doc """
|
||||
Executes this cache warmer.
|
||||
"""
|
||||
def execute(_state) do
|
||||
Zcashex.getinfo() |> handle_result()
|
||||
end
|
||||
|
||||
# ignores the warmer result in case of error
|
||||
defp handle_result({:error, _reason}),
|
||||
do: :ignore
|
||||
|
||||
defp handle_result({:ok, info}) do
|
||||
{:ok, [{"info", info}]}
|
||||
end
|
||||
end
|
|
@ -51,7 +51,14 @@ defmodule ZcashExplorerWeb.BlockChainInfoLive do
|
|||
</dd>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="px-4 py-5 bg-white shadow rounded-lg overflow-hidden sm:p-6">
|
||||
<dt class="text-sm font-medium text-gray-500 truncate">
|
||||
zcashd version
|
||||
</dt>
|
||||
<dd class="mt-1 text-3xl font-semibold text-gray-900">
|
||||
<%= @blockchain_info["build"] %>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
@ -65,6 +72,8 @@ defmodule ZcashExplorerWeb.BlockChainInfoLive do
|
|||
|
||||
case Cachex.get(:app_cache, "metrics") do
|
||||
{:ok, info} ->
|
||||
{:ok, %{"build" => build}} = Cachex.get(:app_cache, "info")
|
||||
info = Map.put(info, "build", build)
|
||||
{:ok, assign(socket, :blockchain_info, info)}
|
||||
|
||||
{:error, _reason} ->
|
||||
|
@ -76,6 +85,8 @@ defmodule ZcashExplorerWeb.BlockChainInfoLive do
|
|||
def handle_info(:update, socket) do
|
||||
Process.send_after(self(), :update, 15000)
|
||||
{:ok, info} = Cachex.get(:app_cache, "metrics")
|
||||
{:ok, %{"build" => build}} = Cachex.get(:app_cache, "info")
|
||||
info = Map.put(info, "build", build)
|
||||
{:noreply, assign(socket, :blockchain_info, info)}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue