Skip to content

Commit f1ad896

Browse files
authored
Merge pull request #24 from bcdevtools/imp/improve-validator-web-page-content
imp: improve validator web page content
2 parents e365a22 + 7e22c2a commit f1ad896

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

client/html/index.tmpl

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,24 @@
1717
<meta name="twitter:title" content="{[{ .siteName }]}" />
1818
<meta property="twitter:description" content="{[{ .description }]}" />
1919
<meta property="twitter:image" content="{[{ .logo }]}" />
20+
<meta name="software-version" content="{[{ .binaryVersion }]}" />
2021
<link rel="shortcut icon" href="{[{ .favicon }]}" />
2122
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
2223
<link rel="stylesheet" href="/resources/site.css"/>
23-
{[{ if .brand }]}
2424
<style type="text/css">
2525
.watermark-brand {
2626
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='100px' width='300px' opacity='0.05'><text transform='translate(20, 100) rotate(-25)' fill='rgb(245,45,45)' font-size='46'>{[{ .brand }]}</text></svg>");
2727
}
28+
.brandLink {
29+
text-decoration: none;
30+
color: inherit;
31+
opacity: .3;
32+
}
2833
</style>
29-
{[{ end }]}
3034
</head>
3135
<body class="watermark-brand">
32-
<div id="main" class="container">
33-
<h3 class="mt-3">{[{ .description }]}</h3>
36+
<div id="main" class="container my-3">
37+
<h3>{[{ .description }]}</h3>
3438
{[{ if .logo }]}
3539
<div class="m-3">
3640
<img class="mini-chain-logo" src="{[{ .logo }]}" alt="logo" />
@@ -58,10 +62,11 @@
5862
<div id="collapseLivePeers" class="accordion-collapse collapse show" aria-labelledby="headingLivePeers" data-bs-parent="#accordionMain">
5963
<div class="card card-body">
6064
{[{ if gt .livePeersCount 0 }]}
61-
<p class="text-secondary">{[{ .livePeersCount }]} real-time live peers from our node:</p>
65+
<div>{[{ .livePeersCount }]} live peers:</div>
66+
<div class="text-secondary"><i>real-time data from our node</i></div>
6267
<pre class="border p-2"><code>{[{ .livePeers }]}</code></pre>
6368
{[{ else }]}
64-
<h3 class="text-danger">Live peers temporary not available</h3>
69+
<h3 class="text-danger">Live peers list is temporary not available</h3>
6570
{[{ end }]}
6671
</div>
6772
</div>
@@ -76,7 +81,7 @@
7681
<div class="card card-body">
7782
{[{ if gt .livePeersCount 0 }]}
7883
<p>Download: <a href="/download/addrbook.json">addrbook.json</a></p>
79-
<pre class="border p-2"><code>wget -O addrbook.json https://{[{ .host }]}/download/addrbook.json --inet4-only
84+
<pre class="border p-2"><code>wget -O addrbook.json https://{[{ .host }]}/download/addrbook.json
8085
mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config</code></pre>
8186
{[{ else }]}
8287
<h3 class="text-danger">Addrbook temporary not available</h3>
@@ -112,7 +117,7 @@ mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config</code></pre>
112117
<pre class="border p-2"><code>cp $HOME/{[{ .generalNodeHomeName }]}/data/priv_validator_state.json $HOME/{[{ .generalNodeHomeName }]}/priv_validator_state.json</code></pre>
113118
<p class="text-secondary">Verify <b>`priv_validator_key.json`</b> and the backup are equals</p>
114119
<pre class="border p-2"><code>sleep 10 &amp;&amp; cat $HOME/{[{ .generalNodeHomeName }]}/data/priv_validator_state.json &amp;&amp; cat $HOME/{[{ .generalNodeHomeName }]}/priv_validator_state.json</code></pre>
115-
<p>Reset your node</p>
120+
<p>Reset data of the node</p>
116121
<pre class="border p-2"><code>{[{ .generalBinaryName }]} tendermint unsafe-reset-all --home $HOME/{[{ .generalNodeHomeName }]} --keep-addr-book</code></pre>
117122
<p>Decompress the snapshot to your database location. Your database location under <b>`{[{ .generalNodeHomeName }]}/data`</b> or something like that, depending on the node implementation.</p>
118123
<pre class="border p-2"><code>lz4 -c -d {[{ .snapshot.FileName }]} | tar -x -C $HOME/{[{ .generalNodeHomeName }]}/data</code></pre>
@@ -153,11 +158,13 @@ mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config</code></pre>
153158
<p class="text-warning">Do not state-sync a validator node, instead state-sync a full-node and move data to validator node. Be sure backup and restore <b>`priv_validator_key.json`</b></p>
154159
<p>Our state-sync RPC server for {[{ .chainName }]} is</p>
155160
<pre class="border p-2"><code>{[{ .rpcUrl }]}</code></pre>
156-
<p>
157-
Create a reusable shell script such as <b>`state_sync.sh`</b> with the following code.
158-
The code will fetch important state-sync information (such as block height and trust hash)
159-
from our server and update your <b>`config.toml`</b> file accordingly.
160-
</p>
161+
<div>
162+
<div>Prepare a reusable script <b>`state_sync.sh`</b> with the following code.</div>
163+
<div class="text-secondary">
164+
<i>The code will fetch important state-sync information (such as block height and trust hash)
165+
from RPC server and update your <b>`config.toml`</b> file accordingly.</i>
166+
</div>
167+
</div>
161168
<pre class="border p-2"><code>#!/bin/bash
162169

163170
SNAP_RPC="{[{ .rpcUrl }]}"
@@ -175,7 +182,7 @@ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/{[{ .gener
175182
{[{ end }]}
176183
<p>Stop the node</p>
177184
<pre class="border p-2"><code>sudo systemctl stop {[{ .generalBinaryName }]}</code></pre>
178-
<p>Reset the node</p>
185+
<p>Reset data of the node</p>
179186
<pre class="border p-2"><code>{[{ .generalBinaryName }]} tendermint unsafe-reset-all --home $HOME/{[{ .generalNodeHomeName }]} --keep-addr-book</code></pre>
180187
<p>Execute the script</p>
181188
<pre class="border p-2"><code>sh state_sync.sh</code></pre>
@@ -186,6 +193,13 @@ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/{[{ .gener
186193
</div>
187194
</div>
188195
</div>
196+
<footer class="container mb-3 d-flex align-items-center justify-content-center">
197+
{[{ if eq .brand "Valoper.io" }]}
198+
<div><a class="brandLink" href="{[{ .brandLink }]}">Operating by {[{ .brand }]} with 🛡 and 💛️</a></div>
199+
{[{ else }]}
200+
<div><a class="brandLink" href="{[{ .brandLink }]}">Powered by {[{ .brand }]}</a></div>
201+
{[{ end }]}
202+
</footer>
189203
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
190204
</body>
191205
</html>

client/statik/statik.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/web_server/handle_web_page.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package web_server
22

33
import (
44
"fmt"
5+
"github.com/bcdevtools/node-management/constants"
56
webtypes "github.com/bcdevtools/node-management/services/web_server/types"
67
"github.com/bcdevtools/node-management/types"
78
"github.com/bcdevtools/node-management/utils"
@@ -23,7 +24,7 @@ func HandleWebIndex(c *gin.Context) {
2324
var livePeers string
2425
var livePeersCount int
2526

26-
peers, err := getLivePeers(w.Config())
27+
peers, err := getLivePeers(cfg)
2728
if err != nil {
2829
utils.PrintlnStdErr("ERR: failed to get live peers:", err)
2930
} else {
@@ -37,6 +38,10 @@ func HandleWebIndex(c *gin.Context) {
3738

3839
snapshotInfo := getSnapshotInfo(cfg)
3940

41+
if snapshotInfo.Error != nil && cfg.Debug {
42+
utils.PrintlnStdErr("ERR: failed to get snapshot info:", snapshotInfo.Error)
43+
}
44+
4045
var chainDescriptionLines []string
4146
if cfg.ChainDescription != "" {
4247
chainDescriptionLines = strings.Split(cfg.ChainDescription, "\\n")
@@ -48,6 +53,7 @@ func HandleWebIndex(c *gin.Context) {
4853
c.HTML(http.StatusOK, "index.tmpl", gin.H{
4954
"host": c.Request.Host,
5055
"brand": cfg.Brand,
56+
"brandLink": fmt.Sprintf("https://%s", strings.TrimPrefix(strings.TrimPrefix(strings.TrimPrefix(cfg.Brand, "://"), "http://"), "https://")),
5157
"title": fmt.Sprintf("%s snapshot by %s", cfg.ChainName, cfg.Brand),
5258
"description": fmt.Sprintf("Snapshot data, live-peers, addrbook for %s by %s", cfg.ChainName, cfg.Brand),
5359
"chainName": cfg.ChainName,
@@ -64,6 +70,7 @@ func HandleWebIndex(c *gin.Context) {
6470
"generalNodeHomeName": cfg.GeneralNodeHomeName,
6571
"generalBinaryName": cfg.GeneralBinaryName,
6672
"snapshot": snapshotInfo,
73+
"binaryVersion": constants.VERSION,
6774
})
6875
}
6976

0 commit comments

Comments
 (0)