forked from ethereum/go-ethereum
/
module_explorer.go
357 lines (326 loc) · 18.5 KB
/
module_explorer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
// Copyright 2017 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"bytes"
"fmt"
"text/template"
"math/rand"
"path/filepath"
"strconv"
"strings"
"github.com/ethereum/go-ethereum/log"
)
// explorerDockerfile is the Dockerfile required to run a block explorer.
var explorerDockerfile = `
FROM sidhujag/syscoin-core:latest as syscoin-alpine
FROM sidhujag/blockscout:latest
ENV SYSCOIN_DATA=/home/syscoin/.syscoin
ENV SYSCOIN_VERSION=4.3.0
ENV SYSCOIN_PREFIX=/opt/syscoin-${SYSCOIN_VERSION}
ARG COINSYMBOL={{.Coin}}
ARG COINGECKO_COIN_ID={{.CoingeckoID}}
ARG COINNETWORK={{.Network}}
ARG BLOCK_TRANSFORMER={{.BlockTransformer}}
ARG CSS_PRIMARY={{.CssPrimary}}
ARG CSS_SECONDARY={{.CssSecondary}}
ARG CSS_TERTIARY={{.CssTertiary}}
ARG CSS_PRIMARY_DARK={{.CssPrimaryDark}}
ARG CSS_SECONDARY_DARK={{.CssSecondaryDark}}
ARG CSS_TERTIARY_DARK={{.CssTertiaryDark}}
ARG CSS_FOOTER_BACKGROUND={{.CssFooterBackground}}
ARG CSS_FOOTER_TEXT={{.CssFooterText}}
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/address/_balance_card.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/block/overview.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/transaction/_pending_tile.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/views/wei_helpers.ex; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/priv/gettext/default.pot; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; fi
RUN if [ "$COINNETWORK" != "" ]; then sed -i s/"Ether"/"${COINNETWORK}"/g apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"ETH"/"${COINSYMBOL}"/g apps/block_scout_web/priv/gettext/default.pot; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"xDai"/"${COINSYMBOL}"/g apps/block_scout_web/priv/gettext/default.pot; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"ETH"/"${COINSYMBOL}"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"xDai"/"${COINSYMBOL}"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"xDAI"/"${COINSYMBOL}"/g apps/block_scout_web/priv/gettext/default.pot; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"xDAI"/"${COINSYMBOL}"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"xDAI"/"${COINSYMBOL}"/g apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"ETH"/"${COINSYMBOL}"/g apps/block_scout_web/lib/block_scout_web/templates/address_token/overview.html.eex; fi
RUN if [ "$COINSYMBOL" != "" ]; then sed -i s/"ETH"/"${COINSYMBOL}"/g apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/lib/block_scout_web/templates/address_validation/index.html.eex; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/lib/block_scout_web/views/address_view.ex; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/lib/block_scout_web/templates/transaction/index.html.eex; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/assets/js/pages/address.js; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po; fi
RUN if [ "$BLOCK_TRANSFORMER" == "base" ]; then sed -i s/"Validated"/"Mined"/g apps/block_scout_web/priv/gettext/default.pot; fi
RUN if [ "$CSS_PRIMARY" != "" ]; then sed -i s/"#5c34a2"/"${CSS_PRIMARY}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_PRIMARY" != "" ]; then sed -i s/"#5c34a2"/"${CSS_PRIMARY}"/g apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss; fi
RUN if [ "$CSS_PRIMARY" != "" ]; then sed -i s/"#5b389f"/"${CSS_PRIMARY}"/g apps/block_scout_web/assets/css/theme/_base_variables.scss; fi
RUN if [ "$CSS_SECONDARY" != "" ]; then sed -i s/"#87e1a9"/"${CSS_SECONDARY}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_SECONDARY" != "" ]; then sed -i s/"#87e1a9"/"${CSS_SECONDARY}"/g apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss; fi
RUN if [ "$CSS_SECONDARY" != "" ]; then sed -i s/"#87e1a9"/"${CSS_SECONDARY}"/g apps/block_scout_web/assets/css/theme/_base_variables.scss; fi
RUN if [ "$CSS_TERTIARY" != "" ]; then sed -i s/"#8258cd"/"${CSS_TERTIARY}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_TERTIARY" != "" ]; then sed -i s/"#bf9cff"/"${CSS_TERTIARY}"/g apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss; fi
RUN if [ "$CSS_TERTIARY" != "" ]; then sed -i s/"#997fdc"/"${CSS_TERTIARY}"/g apps/block_scout_web/assets/css/theme/_base_variables.scss; fi
RUN if [ "$CSS_PRIMARY_DARK" != "" ]; then sed -i s/"#9b62ff"/"${CSS_PRIMARY_DARK}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_PRIMARY_DARK" != "" ]; then sed -i s/"#bf9cff"/"${CSS_PRIMARY_DARK}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_PRIMARY_DARK" != "" ]; then sed -i s/"#9b62ff"/"${CSS_PRIMARY_DARK}"/g apps/block_scout_web/assets/css/theme/_base_variables.scss; fi
RUN if [ "$CSS_SECONDARY_DARK" != "" ]; then sed -i s/"#87e1a9"/"${CSS_SECONDARY_DARK}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_SECONDARY_DARK" != "" ]; then sed -i s/"#87e1a9"/"${CSS_SECONDARY_DARK}"/g apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss; fi
RUN if [ "$CSS_SECONDARY_DARK" != "" ]; then sed -i s/"#87e1a9"/"${CSS_SECONDARY_DARK}"/g apps/block_scout_web/assets/css/theme/_base_variables.scss; fi
RUN if [ "$CSS_TERTIARY_DARK" != "" ]; then sed -i s/"#7e50d0"/"${CSS_TERTIARY_DARK}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_FOOTER_BACKGROUND" != "" ]; then sed -i s/"#3c226a"/"${CSS_FOOTER_BACKGROUND}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_FOOTER_TEXT" != "" ]; then sed -i s/"#bda6e7"/"${CSS_FOOTER_TEXT}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$CSS_FOOTER_TEXT" != "" ]; then sed -i s/"#dcc8ff"/"${CSS_FOOTER_TEXT}"/g apps/block_scout_web/assets/css/theme/_neutral_variables.scss; fi
RUN if [ "$COINGECKO_COIN_ID" != "" ]; then sed -i s/"ethereum"/"${COINGECKO_COIN_ID}"/g apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex; fi
RUN sed -i s/"1 <<< 30"/"50 <<< 30"/g apps/indexer/config/config.exs
RUN sed -i s/"1 <<< 30"/"50 <<< 30"/g apps/indexer/lib/indexer/memory/monitor.ex
RUN sed -i s/"20_000_000"/"200_000_000"/g apps/block_scout_web/lib/block_scout_web/endpoint.ex
RUN mix phx.digest.clean --keep 0
RUN cd apps/block_scout_web/assets/ && \
npm install && \
npm run deploy && \
cd -
RUN cd apps/explorer/ && \
npm install && \
cd -
RUN mix phx.digest
RUN rm /usr/local/bin/geth
COPY --from=syscoin-alpine ${SYSCOIN_DATA}/* /opt/app/.syscoin/
COPY --from=syscoin-alpine ${SYSCOIN_PREFIX}/bin/* /usr/local/bin/
ENV NETWORK={{.Network}} \
SUBNETWORK={{.SubNetwork}} \
COINGECKO_COIN_ID={{.CoingeckoID}} \
COIN={{.Coin}} \
LOGO={{.Logo}} \
LOGO_FOOTER={{.LogoFooter}} \
LOGO_TEXT={{.LogoText}} \
CHAIN_ID={{.NetworkID}} \
HEALTHY_BLOCKS_PERIOD={{.HealthyBlockPeriod}} \
SUPPORTED_CHAINS='{{.SupportedChains}}' \
BLOCK_TRANSFORMER={{.BlockTransformer}} \
SHOW_TXS_CHART={{.ShowTxChart}} \
DISABLE_EXCHANGE_RATES={{.DisableExchangeRates}} \
SHOW_PRICE_CHART={{.ShowPriceChart}} \
ETHEREUM_JSONRPC_HTTP_URL={{.HttpUrl}} \
ETHEREUM_JSONRPC_WS_URL={{.WsUrl}} \
BLOCKSCOUT_PROTOCOL={{.BlockscoutProtocol}} \
BLOCKSCOUT_HOST={{.BlockscoutHost}} \
ENABLE_SOURCIFY_INTEGRATION=true \
DISPLAY_TOKEN_ICONS=true \
GAS_PRICE=1
RUN \
echo $'LC_ALL=C syscoind {{if eq .NetworkID 5700}}--testnet --addnode=3.15.199.152{{end}} --datadir=/opt/app/.syscoin --disablewallet --gethcommandline=--syncmode="full" --gethcommandline=--gcmode="archive" --gethcommandline=--port={{.EthPort}} --gethcommandline=--bootnodes={{.Bootnodes}} --gethcommandline=--ethstats={{.Ethstats}} --gethcommandline=--cache=8192 --gethcommandline=--http --gethcommandline=--http.api="net,web3,eth,debug,txpool" --gethcommandline=--http.corsdomain="*" --gethcommandline=--http.vhosts="*" --gethcommandline=--ws --gethcommandline=--ws.origins="*" --gethcommandline=--exitwhensynced' >> explorer.sh && \
echo $'LC_ALL=C exec syscoind {{if eq .NetworkID 5700}}--testnet --addnode=3.15.199.152{{end}} --datadir=/opt/app/.syscoin --disablewallet --gethcommandline=--syncmode="full" --gethcommandline=--gcmode="archive" --gethcommandline=--port={{.EthPort}} --gethcommandline=--bootnodes={{.Bootnodes}} --gethcommandline=--ethstats={{.Ethstats}} --gethcommandline=--cache=8192 --gethcommandline=--http --gethcommandline=--http.api="net,web3,eth,debug,txpool" --gethcommandline=--http.corsdomain="*" --gethcommandline=--http.vhosts="*" --gethcommandline=--ws --gethcommandline=--ws.origins="*" &' >> explorer.sh && \
echo '/usr/local/bin/docker-entrypoint.sh postgres &' >> explorer.sh && \
echo 'sleep 5' >> explorer.sh && \
echo 'mix do ecto.drop --force, ecto.create, ecto.migrate' >> explorer.sh && \
echo 'mix phx.server' >> explorer.sh
ENTRYPOINT ["/bin/sh", "explorer.sh"]
`
// explorerComposefile is the docker-compose.yml file required to deploy and
// maintain a block explorer.
var explorerComposefile = `
version: '2'
services:
explorer:
build: .
image: {{.Network}}/explorer
container_name: {{.Network}}_explorer_1
ports:
- "{{.EthPort}}:{{.EthPort}}"
- "{{.SysPort1}}:{{.SysPort1}}"
- "{{.SysPort2}}:{{.SysPort2}}"
- "{{.SysPort3}}:{{.SysPort3}}"
- "{{.EthPort}}:{{.EthPort}}/udp"{{if not .VHost}}
- "{{.WebPort}}:4000"{{end}}
environment:
- ETH_PORT={{.EthPort}}
- ETH_NAME={{.EthName}}
- BLOCK_TRANSFORMER={{.Transformer}}{{if .VHost}}
- VIRTUAL_HOST={{.VHost}}
- VIRTUAL_PORT=4000{{end}}
volumes:
- {{.Datadir}}:/opt/app/.syscoin
- {{.DBDir}}:/var/lib/postgresql/data
logging:
driver: "json-file"
options:
max-size: "1m"
max-file: "10"
restart: always
`
// deployExplorer deploys a new block explorer container to a remote machine via
// SSH, docker and docker-compose. If an instance with the specified network name
// already exists there, it will be overwritten!
func deployExplorer(client *sshClient, network string, bootnodes []string, config *explorerInfos, nocache bool, isClique bool) ([]byte, error) {
// Generate the content to upload to the server
workdir := fmt.Sprintf("%d", rand.Int63())
files := make(map[string][]byte)
transformer := "base"
if isClique {
transformer = "clique"
}
dockerfile := new(bytes.Buffer)
subNetwork := ""
showPriceChart := "true"
disableExchangeRates := "false"
supportedChains := `[{"title":"Tanenbaum Testnet","url":"https://tanenbaum.io","test_net?":true},{"title":"Syscoin Mainnet","url":"https://explorer.syscoin.org"}]`
if config.node.network == 5700 {
subNetwork = "Tanenbaum"
disableExchangeRates = "false"
showPriceChart = "true"
}
protocol := "https"
host := config.host
if host == "" {
host = client.server
protocol = "http"
}
template.Must(template.New("").Parse(explorerDockerfile)).Execute(dockerfile, map[string]interface{}{
"NetworkID": config.node.network,
"Bootnodes": strings.Join(bootnodes, ","),
"Ethstats": config.node.ethstats,
"EthPort": config.node.port,
"HttpUrl": "http://localhost:8545",
"WsUrl": "ws://localhost:8546",
"Network": "Syscoin",
"SubNetwork": subNetwork,
"CoingeckoID": "syscoin",
"Coin": "SYS",
"Logo": "/images/sys_logo.svg",
"LogoFooter": "/images/sys_logo.svg",
"LogoText": "NEVM",
"HealthyBlockPeriod": 34500000,
"SupportedChains": supportedChains,
"BlockTransformer": transformer,
"BlockscoutProtocol": protocol,
"BlockscoutHost": host,
"ShowTxChart": "true",
"DisableExchangeRates": disableExchangeRates,
"ShowPriceChart": showPriceChart,
"CssPrimary": "#243066",
"CssSecondary": "#87e1a9",
"CssTertiary": "#344180",
"CssPrimaryDark": "#6fb8df",
"CssSecondaryDark": "#87e1a9",
"CssTertiaryDark": "#243066",
"CssFooterBackground": "#101d48",
"CssFooterText": "#6fb8df",
})
files[filepath.Join(workdir, "Dockerfile")] = dockerfile.Bytes()
composefile := new(bytes.Buffer)
template.Must(template.New("").Parse(explorerComposefile)).Execute(composefile, map[string]interface{}{
"Network": network,
"VHost": config.host,
"Ethstats": config.node.ethstats,
"Datadir": config.node.datadir,
"DBDir": config.dbdir,
"EthPort": config.node.port,
"SysPort1": 8369,
"SysPort2": 18369,
"SysPort3": 18444,
"EthName": config.node.ethstats[:strings.Index(config.node.ethstats, ":")],
"WebPort": config.port,
"Transformer": transformer,
})
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
files[filepath.Join(workdir, "genesis.json")] = config.node.genesis
// Upload the deployment files to the remote server (and clean up afterwards)
if out, err := client.Upload(files); err != nil {
return out, err
}
defer client.Run("rm -rf " + workdir)
// Build and deploy the boot or seal node service
if nocache {
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate --timeout 60", workdir, network, network))
}
return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate --timeout 60", workdir, network))
}
// explorerInfos is returned from a block explorer status check to allow reporting
// various configuration parameters.
type explorerInfos struct {
node *nodeInfos
dbdir string
host string
port int
}
// Report converts the typed struct into a plain string->string map, containing
// most - but not all - fields for reporting to the user.
func (info *explorerInfos) Report() map[string]string {
report := map[string]string{
"Website address ": info.host,
"Website listener port ": strconv.Itoa(info.port),
"Ethereum listener port ": strconv.Itoa(info.node.port),
"Ethstats username": info.node.ethstats,
}
return report
}
// checkExplorer does a health-check against a block explorer server to verify
// whether it's running, and if yes, whether it's responsive.
func checkExplorer(client *sshClient, network string) (*explorerInfos, error) {
// Inspect a possible explorer container on the host
infos, err := inspectContainer(client, fmt.Sprintf("%s_explorer_1", network))
if err != nil {
return nil, err
}
if !infos.running {
return nil, ErrServiceOffline
}
// Resolve the port from the host, or the reverse proxy
port := infos.portmap["4000/tcp"]
if port == 0 {
if proxy, _ := checkNginx(client, network); proxy != nil {
port = proxy.port
}
}
if port == 0 {
return nil, ErrNotExposed
}
// Resolve the host from the reverse-proxy and the config values
host := infos.envvars["VIRTUAL_HOST"]
if host == "" {
host = client.server
}
// Run a sanity check to see if the devp2p is reachable
p2pPort := infos.portmap[infos.envvars["ETH_PORT"]+"/tcp"]
if err = checkPort(host, p2pPort); err != nil {
log.Warn("Explorer node seems unreachable", "server", host, "port", p2pPort, "err", err)
}
if err = checkPort(host, port); err != nil {
log.Warn("Explorer service seems unreachable", "server", host, "port", port, "err", err)
}
// Assemble and return the useful infos
stats := &explorerInfos{
node: &nodeInfos{
datadir: infos.volumes["/opt/app/.syscoin"],
port: infos.portmap[infos.envvars["ETH_PORT"]+"/tcp"],
ethstats: infos.envvars["ETH_NAME"],
},
dbdir: infos.volumes["/var/lib/postgresql/data"],
host: host,
port: port,
}
return stats, nil
}