Fix splitting of indexer/web components setup
@ -7,6 +7,7 @@
- [#2834](https://github.com/poanetwork/blockscout/pull/2834) - always redirect to checksummed hash
### Fixes
- [#3025](https://github.com/poanetwork/blockscout/pull/3025) - Fix splitting of indexer/web components setup
- [#3024](https://github.com/poanetwork/blockscout/pull/3024) - Fix pool size default value in config
- [#3021](https://github.com/poanetwork/blockscout/pull/3021), [#3022](https://github.com/poanetwork/blockscout/pull/3022) - Refine dev/test config
- [#3016](https://github.com/poanetwork/blockscout/pull/3016), [#3017](https://github.com/poanetwork/blockscout/pull/3017) - Fix token instance QR code data
@ -4055,6 +4055,17 @@ defmodule Explorer.Chain do
defp boolean_to_check_result(false), do: :not_found
def extract_db_name(db_url) do
if db_url == nil do
""
else
db_url
|> String.split("/")
|> Enum.take(-1)
|> Enum.at(0)
end
@doc """
Fetches the first trace from the Parity trace URL.
"""
@ -6,15 +6,22 @@ defmodule Explorer.Chain.Events.Listener do
use GenServer
alias Postgrex.Notifications
import Explorer.Chain, only: [extract_db_name: 1]
def start_link(_) do
GenServer.start_link(__MODULE__, "chain_event", name: __MODULE__)
def init(channel) do
{:ok, pid} =
explorer_repo =
:explorer
|> Application.get_env(Explorer.Repo)
db_url = explorer_repo[:url]
explorer_repo
|> Keyword.put(:database, extract_db_name(db_url))
|> Notifications.start_link()
ref = Notifications.listen!(pid, channel)
@ -4870,6 +4870,23 @@ defmodule Explorer.ChainTest do
describe "extract_db_name/1" do
test "extracts correct db name" do
db_url = "postgresql://viktor:@localhost:5432/blockscout-dev-1"
assert Chain.extract_db_name(db_url) == "blockscout-dev-1"
test "returns empty db name" do
db_url = ""
assert Chain.extract_db_name(db_url) == ""
test "returns nil db name" do
db_url = nil
describe "fetch_first_trace/2" do
test "fetched first trace", %{
json_rpc_named_arguments: json_rpc_named_arguments