Commit 48962ac9 authored by protolambda's avatar protolambda

op-node: static-peers list local-peer check and flag description update

parent 413aac1e
......@@ -189,8 +189,9 @@ func P2PFlags(envPrefix string) []cli.Flag {
EnvVars: p2pEnv(envPrefix, "BOOTNODES"),
},
&cli.StringFlag{
Name: StaticPeersName,
Usage: "Comma-separated multiaddr-format peer list. Static connections to make and maintain, these peers will be regarded as trusted.",
Name: StaticPeersName,
Usage: "Comma-separated multiaddr-format peer list. Static connections to make and maintain, these peers will be regarded as trusted. " +
"Addresses of the local peer are ignored. Duplicate/Alternative addresses for the same peer all apply, but only a single connection per peer is maintained.",
Required: false,
Value: "",
EnvVars: p2pEnv(envPrefix, "STATIC"),
......
......@@ -229,13 +229,17 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter, metrics Host
return nil, err
}
staticPeers := make([]*peer.AddrInfo, len(conf.StaticPeers))
for i, peerAddr := range conf.StaticPeers {
staticPeers := make([]*peer.AddrInfo, 0, len(conf.StaticPeers))
for _, peerAddr := range conf.StaticPeers {
addr, err := peer.AddrInfoFromP2pAddr(peerAddr)
if err != nil {
return nil, fmt.Errorf("bad peer address: %w", err)
}
staticPeers[i] = addr
if addr.ID == h.ID() {
log.Info("Static-peer list contains address of local peer, ignoring the address.", "address", addr)
continue
}
staticPeers = append(staticPeers, addr)
}
out := &extraHost{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment