mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
abfa374165
* separated convertions into utils.go * added log to bad peers * more verbose errors and names * warn when banning bad peer * has and get in function name * space * lint * ops * little rename * deleted unused func * revert
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/lightclient/clparams"
|
|
"github.com/ledgerwatch/erigon/cmd/lightclient/sentinel"
|
|
"github.com/ledgerwatch/log/v3"
|
|
)
|
|
|
|
var (
|
|
defaultIpAddr = "127.0.0.1" // Localhost
|
|
defaultPort = 8080
|
|
defaultTcpPort = uint(9000)
|
|
)
|
|
|
|
func main() {
|
|
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler))
|
|
discCfg, err := clparams.GetDefaultDiscoveryConfig(clparams.MainnetNetwork)
|
|
if err != nil {
|
|
log.Error("error", "err", err)
|
|
return
|
|
}
|
|
sent, err := sentinel.New(context.Background(), sentinel.SentinelConfig{
|
|
IpAddr: defaultIpAddr,
|
|
Port: defaultPort,
|
|
TCPPort: defaultTcpPort,
|
|
DiscoverConfig: *discCfg,
|
|
})
|
|
if err != nil {
|
|
log.Error("error", "err", err)
|
|
return
|
|
}
|
|
if err := sent.Start(); err != nil {
|
|
log.Error("failed to start sentinel", "err", err)
|
|
return
|
|
}
|
|
log.Info("Sentinel started", "enr", sent.String())
|
|
logInterval := time.NewTicker(5 * time.Second)
|
|
for {
|
|
select {
|
|
case <-logInterval.C:
|
|
log.Info("[Lighclient] Networking Report", "peers", sent.GetPeersCount())
|
|
default:
|
|
time.Sleep(100 * time.Millisecond)
|
|
}
|
|
}
|
|
}
|