From 2ddc1b9747d1078e37a8c678d165d3ae2d1c840b Mon Sep 17 00:00:00 2001 From: Peter Romfeld Date: Wed, 25 Jul 2018 14:36:10 +0800 Subject: [PATCH 1/3] get geth_url from environment and fix `variant` for {dev,prod}.exs --- apps/explorer/config/dev.exs | 10 +++++++++- apps/explorer/config/dev/geth.exs | 2 +- apps/explorer/config/prod.exs | 10 +++++++++- apps/explorer/config/prod/geth.exs | 2 +- apps/indexer/config/dev.exs | 10 +++++++++- apps/indexer/config/dev/geth.exs | 2 +- apps/indexer/config/prod.exs | 10 +++++++++- apps/indexer/config/prod/geth.exs | 2 +- 8 files changed, 40 insertions(+), 8 deletions(-) diff --git a/apps/explorer/config/dev.exs b/apps/explorer/config/dev.exs index 34d867dbff..345769b41a 100644 --- a/apps/explorer/config/dev.exs +++ b/apps/explorer/config/dev.exs @@ -12,7 +12,15 @@ config :explorer, Explorer.Repo, import_config "dev.secret.exs" -variant = System.get_env("ETHEREUM_JSONRPC_VARIANT") || "parity" +variant = + if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do + "parity" + else + System.get_env("ETHEREUM_JSONRPC_VARIANT") + |> String.split(".") + |> List.last() + |> String.downcase() + end # Import variant specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/apps/explorer/config/dev/geth.exs b/apps/explorer/config/dev/geth.exs index ecca69709e..fb1ebe46d8 100644 --- a/apps/explorer/config/dev/geth.exs +++ b/apps/explorer/config/dev/geth.exs @@ -5,7 +5,7 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/explorer/config/prod.exs b/apps/explorer/config/prod.exs index 4f9748a5cf..b9cd9b0a2b 100644 --- a/apps/explorer/config/prod.exs +++ b/apps/explorer/config/prod.exs @@ -9,7 +9,15 @@ config :explorer, Explorer.Repo, prepare: :unnamed, timeout: 60_000 -variant = System.get_env("ETHEREUM_JSONRPC_VARIANT") || "parity" +variant = + if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do + "parity" + else + System.get_env("ETHEREUM_JSONRPC_VARIANT") + |> String.split(".") + |> List.last() + |> String.downcase() + end # Import variant specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/apps/explorer/config/prod/geth.exs b/apps/explorer/config/prod/geth.exs index ecca69709e..fb1ebe46d8 100644 --- a/apps/explorer/config/prod/geth.exs +++ b/apps/explorer/config/prod/geth.exs @@ -5,7 +5,7 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/indexer/config/dev.exs b/apps/indexer/config/dev.exs index 8acaef59e8..9ae4b06f25 100644 --- a/apps/indexer/config/dev.exs +++ b/apps/indexer/config/dev.exs @@ -1,6 +1,14 @@ use Mix.Config -variant = System.get_env("ETHEREUM_JSONRPC_VARIANT") || "parity" +variant = + if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do + "parity" + else + System.get_env("ETHEREUM_JSONRPC_VARIANT") + |> String.split(".") + |> List.last() + |> String.downcase() + end # Import variant specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/apps/indexer/config/dev/geth.exs b/apps/indexer/config/dev/geth.exs index ec004dbb88..afadbab008 100644 --- a/apps/indexer/config/dev/geth.exs +++ b/apps/indexer/config/dev/geth.exs @@ -6,7 +6,7 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/indexer/config/prod.exs b/apps/indexer/config/prod.exs index 73d679df2c..8c22a4364b 100644 --- a/apps/indexer/config/prod.exs +++ b/apps/indexer/config/prod.exs @@ -1,6 +1,14 @@ use Mix.Config -variant = System.get_env("ETHEREUM_JSONRPC_VARIANT") || "parity" +variant = + if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do + "parity" + else + System.get_env("ETHEREUM_JSONRPC_VARIANT") + |> String.split(".") + |> List.last() + |> String.downcase() + end # Import variant specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/apps/indexer/config/prod/geth.exs b/apps/indexer/config/prod/geth.exs index ec004dbb88..afadbab008 100644 --- a/apps/indexer/config/prod/geth.exs +++ b/apps/indexer/config/prod/geth.exs @@ -6,7 +6,7 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth From b473420df393241d1d44f29285d45f2140929385 Mon Sep 17 00:00:00 2001 From: Peter Romfeld Date: Wed, 25 Jul 2018 14:41:20 +0800 Subject: [PATCH 2/3] use ETHEREUM_JSONRPC_HTTP_URL instead --- apps/explorer/config/dev/geth.exs | 4 +++- apps/explorer/config/prod/geth.exs | 4 +++- apps/indexer/config/dev/geth.exs | 4 +++- apps/indexer/config/prod/geth.exs | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/explorer/config/dev/geth.exs b/apps/explorer/config/dev/geth.exs index fb1ebe46d8..f2b0739dbd 100644 --- a/apps/explorer/config/dev/geth.exs +++ b/apps/explorer/config/dev/geth.exs @@ -5,7 +5,9 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: + System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || + "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/explorer/config/prod/geth.exs b/apps/explorer/config/prod/geth.exs index fb1ebe46d8..f2b0739dbd 100644 --- a/apps/explorer/config/prod/geth.exs +++ b/apps/explorer/config/prod/geth.exs @@ -5,7 +5,9 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: + System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || + "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/indexer/config/dev/geth.exs b/apps/indexer/config/dev/geth.exs index afadbab008..7092bc4f9a 100644 --- a/apps/indexer/config/dev/geth.exs +++ b/apps/indexer/config/dev/geth.exs @@ -6,7 +6,9 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: + System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || + "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/indexer/config/prod/geth.exs b/apps/indexer/config/prod/geth.exs index afadbab008..7092bc4f9a 100644 --- a/apps/indexer/config/prod/geth.exs +++ b/apps/indexer/config/prod/geth.exs @@ -6,7 +6,9 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: System.get_env("GETH_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: + System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || + "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth From d9e37c44a62beafb8b6b77a8c2d66ee93f5383a4 Mon Sep 17 00:00:00 2001 From: Peter Romfeld Date: Wed, 25 Jul 2018 15:18:21 +0800 Subject: [PATCH 3/3] fix formatting --- apps/explorer/config/dev/geth.exs | 4 +--- apps/explorer/config/prod/geth.exs | 4 +--- apps/indexer/config/dev/geth.exs | 4 +--- apps/indexer/config/prod/geth.exs | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/apps/explorer/config/dev/geth.exs b/apps/explorer/config/dev/geth.exs index f2b0739dbd..a97bb49f3f 100644 --- a/apps/explorer/config/dev/geth.exs +++ b/apps/explorer/config/dev/geth.exs @@ -5,9 +5,7 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: - System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || - "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/explorer/config/prod/geth.exs b/apps/explorer/config/prod/geth.exs index f2b0739dbd..a97bb49f3f 100644 --- a/apps/explorer/config/prod/geth.exs +++ b/apps/explorer/config/prod/geth.exs @@ -5,9 +5,7 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: - System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || - "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/indexer/config/dev/geth.exs b/apps/indexer/config/dev/geth.exs index 7092bc4f9a..f54da8909a 100644 --- a/apps/indexer/config/dev/geth.exs +++ b/apps/indexer/config/dev/geth.exs @@ -6,9 +6,7 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: - System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || - "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth diff --git a/apps/indexer/config/prod/geth.exs b/apps/indexer/config/prod/geth.exs index 7092bc4f9a..f54da8909a 100644 --- a/apps/indexer/config/prod/geth.exs +++ b/apps/indexer/config/prod/geth.exs @@ -6,9 +6,7 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: - System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || - "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://mainnet.infura.io/8lTvJTKmHPCHazkneJsY", http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], variant: EthereumJSONRPC.Geth