mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
d9c0e65cef
* info logs beacon node improvements * prom test fixes * info logging changes * wrapped up node info logging * changed to debug level * warn logs taken care of * Terence suggestion * warn spacing * better logging in initial sync * debug level standardized * complete debug standardization * participation at epoch end * fix archive tests * even more test fixes * prom test * ops test * powtest * rpc sync test * rem part * log formatting
37 lines
906 B
Go
37 lines
906 B
Go
package p2p
|
|
|
|
import (
|
|
"github.com/libp2p/go-libp2p/config"
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
// withRelayAddrs returns an AddrFactory which will return Multiaddr via
|
|
// specified relay string in addition to existing MultiAddr.
|
|
func withRelayAddrs(relay string) config.AddrsFactory {
|
|
return func(addrs []ma.Multiaddr) []ma.Multiaddr {
|
|
if relay == "" {
|
|
return addrs
|
|
}
|
|
|
|
var relayAddrs []ma.Multiaddr
|
|
|
|
for _, a := range addrs {
|
|
if a.String() == "/p2p-circuit" {
|
|
continue
|
|
}
|
|
relayAddr, err := ma.NewMultiaddr(relay + "/p2p-circuit" + a.String())
|
|
if err != nil {
|
|
log.Errorf("Failed to create multiaddress for relay node: %v", err)
|
|
} else {
|
|
relayAddrs = append(relayAddrs, relayAddr)
|
|
}
|
|
}
|
|
|
|
if len(relayAddrs) == 0 {
|
|
log.Warn("Addresses via relay node are zero - using non-relay addresses")
|
|
return addrs
|
|
}
|
|
return append(addrs, relayAddrs...)
|
|
}
|
|
}
|