mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-29 06:37:17 +00:00
c8ce74825e
* Bootstrap the DHT service, add some tracing spans * fix * test fix * dont ignore error
32 lines
650 B
Go
32 lines
650 B
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/libp2p/go-libp2p-host"
|
|
"github.com/libp2p/go-libp2p-peerstore"
|
|
"github.com/multiformats/go-multiaddr"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// MakePeer from multiaddress string.
|
|
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 {
|
|
ctx, span := trace.StartSpan(ctx, "p2p_dialRelayNode")
|
|
defer span.End()
|
|
|
|
p, err := MakePeer(relayAddr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return h.Connect(ctx, *p)
|
|
}
|