Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/.env_sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
WS_SECRET=xinfin_xdpos_hybrid_network_stats
PORT=2000
ENABLE_FORENSICS=false
MONGODBURL=localhost:27017
MONGODBURL=localhost:27017

# Bootnode health (optional)
# ENABLE_BOOTNODE_HEALTH=true
# BOOTNODE_NETWORK=devnet
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine AS builder
FROM golang:1.25-alpine AS builder
WORKDIR /build

COPY go.mod go.sum ./
Expand Down
15 changes: 15 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ Copy `.env_sample` to `.env` and fill in the values.
| `MONGODBURL` | `localhost:27017` | MongoDB host:port |
| `MASTERNODE_URL` | `https://master.xinfin.network/api` | Masternode API base URL |
| `VERBOSITY` | `1` | Log verbosity level |
| `ENABLE_BOOTNODE_HEALTH` | `true` | Set to `false` to disable bootnode UDP/TCP probes |
| `BOOTNODE_NETWORK` | `mainnet` | Network for bootnode probes (`mainnet`, `testnet`, or `devnet`) |
| `BOOTNODE_CHECK_INTERVAL` | `60` | Seconds between automatic bootnode health checks |
| `BOOTNODE_CHECK_TIMEOUT` | `5` | Per-check timeout in seconds |
| `BOOTNODE_CHECK_PARALLEL` | `8` | Parallel workers for bootnode probes |

Bootnode lists default to the official XinFin-Node files on GitHub:

- Mainnet: [mainnet/bootnodes.list](https://github.com/XinFinOrg/XinFin-Node/blob/master/mainnet/bootnodes.list)
- Testnet: [testnet/bootnodes.list](https://github.com/XinFinOrg/XinFin-Node/blob/master/testnet/bootnodes.list)
- Devnet: hardcoded placeholder in `internal/service/bootnode_load.go` (`TODO` — update IP/enode when official devnet bootnodes are available)

The list is re-fetched from GitHub before each health check so updates in XinFin-Node are picked up automatically.

Bootnode UDP/TCP probes depend on [XDPoSChain](https://github.com/XinFinOrg/XDPoSChain) `feat/discv4-ping-export` (pinned as `v1.6.1-0.20260621231742-90647d00de10` in `go.mod`).

---

Expand Down
37 changes: 37 additions & 0 deletions backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"strconv"
"strings"
"time"
)

type Config struct {
Expand All @@ -14,6 +15,12 @@ type Config struct {
EnableForensics bool
MasterNodeURL string
GeoIPDBPath string

EnableBootnodeHealth bool
BootnodeNetwork string
BootnodeInterval time.Duration
BootnodeTimeout time.Duration
BootnodeParallel int
}

func Load() *Config {
Expand All @@ -40,6 +47,30 @@ func Load() *Config {
masternodeURL = "https://master.xinfin.network/api"
}

enableBootnodeHealth := os.Getenv("ENABLE_BOOTNODE_HEALTH") != "false"
bootnodeInterval := 60 * time.Second
if v := os.Getenv("BOOTNODE_CHECK_INTERVAL"); v != "" {
if secs, err := strconv.Atoi(v); err == nil && secs > 0 {
bootnodeInterval = time.Duration(secs) * time.Second
}
}
bootnodeTimeout := 5 * time.Second
if v := os.Getenv("BOOTNODE_CHECK_TIMEOUT"); v != "" {
if secs, err := strconv.Atoi(v); err == nil && secs > 0 {
bootnodeTimeout = time.Duration(secs) * time.Second
}
}
bootnodeParallel := 8
if v := os.Getenv("BOOTNODE_CHECK_PARALLEL"); v != "" {
if n, err := strconv.Atoi(v); err == nil && n > 0 {
bootnodeParallel = n
}
}
bootnodeNetwork := os.Getenv("BOOTNODE_NETWORK")
if bootnodeNetwork == "" {
bootnodeNetwork = "mainnet"
}

return &Config{
Port: port,
WSSecrets: secrets,
Expand All @@ -48,5 +79,11 @@ func Load() *Config {
EnableForensics: os.Getenv("ENABLE_FORENSICS") == "true",
MasterNodeURL: masternodeURL,
GeoIPDBPath: os.Getenv("GEOIP_DB_PATH"),

EnableBootnodeHealth: enableBootnodeHealth,
BootnodeNetwork: bootnodeNetwork,
BootnodeInterval: bootnodeInterval,
BootnodeTimeout: bootnodeTimeout,
BootnodeParallel: bootnodeParallel,
}
}
27 changes: 19 additions & 8 deletions backend/go.mod
Original file line number Diff line number Diff line change
@@ -1,47 +1,58 @@
module github.com/XinFinOrg/XDCStats/backend

go 1.23
go 1.25

require (
github.com/XinFinOrg/XDPoSChain v1.6.1-0.20260621231742-90647d00de10
github.com/gin-gonic/gin v1.10.0
github.com/gorilla/websocket v1.5.3
github.com/oschwald/geoip2-golang v1.11.0
go.mongodb.org/mongo-driver/v2 v2.0.1
)

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/oschwald/maxminddb-golang v1.13.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading