mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-29 06:37:17 +00:00
0559d01261
* Preliminary support for relay nodes * lint * Add comment, remove TODO * work on relay address factory * dial relay node, if available * forgot new files * fix service registry breakage * added logging * Added a peer count with prometheus * always start mDNS * fix lint
27 lines
511 B
Go
27 lines
511 B
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/libp2p/go-libp2p-host"
|
|
"github.com/libp2p/go-libp2p-peerstore"
|
|
"github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
func makePeer(addr string) (*peerstore.PeerInfo, error) {
|
|
maddr, err := multiaddr.NewMultiaddr(addr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return peerstore.InfoFromP2pAddr(maddr)
|
|
}
|
|
|
|
func dialRelayNode(ctx context.Context, h host.Host, relayAddr string) error {
|
|
p, err := makePeer(relayAddr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return h.Connect(ctx, *p)
|
|
}
|