Merge branch 'master' into ab-token-transfer-on-transaction-page

pull/1777/head
Ayrat Badykov 6 years ago committed by GitHub
commit 7bf690de43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex
  3. 2
      apps/indexer/config/prod/parity.exs
  4. 2
      apps/indexer/config/prod/rsk.exs
  5. 31
      apps/indexer/lib/indexer/block/realtime/fetcher.ex
  6. 10
      apps/indexer/lib/indexer/block/realtime/supervisor.ex

@ -14,9 +14,11 @@
- [#1740](https://github.com/poanetwork/blockscout/pull/1740) - fix empty block time
- [#1743](https://github.com/poanetwork/blockscout/pull/1743) - sort decompiled smart contracts in lexicographical order
- [#1756](https://github.com/poanetwork/blockscout/pull/1756) - add today's token balance from the previous value
- [#1778](https://github.com/poanetwork/blockscout/pull/1778) - Make websocket optional for realtime fetcher
### Chore
- [#1757](https://github.com/poanetwork/blockscout/pull/1757) - Change twitter acc link to official Blockscout acc twitter
- [#1749](https://github.com/poanetwork/blockscout/pull/1749) - Replace the link in the footer with the official POA announcements tg channel link
- [#1718](https://github.com/poanetwork/blockscout/pull/1718) - Flatten indexer module hierarchy and supervisor tree
- [#1753](https://github.com/poanetwork/blockscout/pull/1753) - Add a check mark to decompiled contract tab

@ -14,7 +14,7 @@
<a href="https://github.com/poanetwork" rel="noreferrer" target="_blank" class="icon-link" data-toggle="tooltip" data-placement="top" title="<%= gettext("Github") %>">
<i class="fab fa-github"></i>
</a>
<a href="https://www.twitter.com/PoaNetwork/" rel="noreferrer" target="_blank" class="icon-link" data-toggle="tooltip" data-placement="top" title="<%= gettext("Twitter") %>">
<a href="https://www.twitter.com/_blockscout/" rel="noreferrer" target="_blank" class="icon-link" data-toggle="tooltip" data-placement="top" title="<%= gettext("Twitter") %>">
<i class="fab fa-twitter"></i>
</a>
<a href="https://t.me/poa_network" rel="noreferrer" target="_blank" class="icon-link" data-toggle="tooltip" data-placement="top" title="<%= gettext("Telegram") %>">

@ -17,7 +17,7 @@ config :indexer,
variant: EthereumJSONRPC.Parity
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
transport: System.get_env("ETHEREUM_JSONRPC_WS_URL") && EthereumJSONRPC.WebSocket,
transport_options: [
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: System.get_env("ETHEREUM_JSONRPC_WS_URL")

@ -19,7 +19,7 @@ config :indexer,
variant: EthereumJSONRPC.RSK
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
transport: System.get_env("ETHEREUM_JSONRPC_WS_URL") && EthereumJSONRPC.WebSocket,
transport_options: [
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: System.get_env("ETHEREUM_JSONRPC_WS_URL")

@ -57,8 +57,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
end
@impl GenServer
def init(%{block_fetcher: %Block.Fetcher{} = block_fetcher, subscribe_named_arguments: subscribe_named_arguments})
when is_list(subscribe_named_arguments) do
def init(%{block_fetcher: %Block.Fetcher{} = block_fetcher, subscribe_named_arguments: subscribe_named_arguments}) do
Logger.metadata(fetcher: :block_realtime)
{:ok, %__MODULE__{block_fetcher: %Block.Fetcher{block_fetcher | broadcast: :realtime, callback_module: __MODULE__}},
@ -66,17 +65,9 @@ defmodule Indexer.Block.Realtime.Fetcher do
end
@impl GenServer
def handle_continue({:init, subscribe_named_arguments}, %__MODULE__{subscription: nil} = state)
when is_list(subscribe_named_arguments) do
case EthereumJSONRPC.subscribe("newHeads", subscribe_named_arguments) do
{:ok, subscription} ->
timer = schedule_polling()
{:noreply, %__MODULE__{state | subscription: subscription, timer: timer}}
{:error, reason} ->
{:stop, reason, state}
end
def handle_continue({:init, subscribe_named_arguments}, %__MODULE__{subscription: nil} = state) do
timer = schedule_polling()
{:noreply, %__MODULE__{state | timer: timer} |> subscribe_to_new_heads(subscribe_named_arguments)}
end
@impl GenServer
@ -141,6 +132,20 @@ defmodule Indexer.Block.Realtime.Fetcher do
}}
end
defp subscribe_to_new_heads(%__MODULE__{subscription: nil} = state, subscribe_named_arguments)
when is_list(subscribe_named_arguments) do
case EthereumJSONRPC.subscribe("newHeads", subscribe_named_arguments) do
{:ok, subscription} ->
%__MODULE__{state | subscription: subscription}
{:error, reason} ->
Logger.debug(fn -> ["Could not connect to websocket: ", reason, ". Continuing with polling."] end)
state
end
end
defp subscribe_to_new_heads(state, _), do: state
defp new_max_number(number, nil), do: number
defp new_max_number(number, max_number_seen), do: max(number, max_number_seen)

@ -34,6 +34,16 @@ defmodule Indexer.Block.Realtime.Supervisor do
[name: Indexer.Block.Realtime.Fetcher]
]}
]
_ ->
[
{Task.Supervisor, name: Indexer.Block.Realtime.TaskSupervisor},
{Indexer.Block.Realtime.Fetcher,
[
%{block_fetcher: block_fetcher, subscribe_named_arguments: nil},
[name: Indexer.Block.Realtime.Fetcher]
]}
]
end
Supervisor.init(children, strategy: :rest_for_one)

Loading…
Cancel
Save