mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
28c4f28d32
* add forked connMgr * gaz * add license header * Merge branch 'master' of https://github.com/prysmaticlabs/geth-sharding into connMgr * add conn manager test * gaz * fix connManager * Merge branch 'master' of https://github.com/prysmaticlabs/geth-sharding into connMgr * gaz * remove todo * add new dep * lint * lint * lint * space * visibility * Merge branch 'master' into connMgr * Merge branch 'master' into connMgr * Merge refs/heads/master into connMgr
31 lines
622 B
Go
31 lines
622 B
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/libp2p/go-libp2p-core/host"
|
|
peerstore "github.com/libp2p/go-libp2p-peerstore"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// MakePeer from multiaddress string.
|
|
func MakePeer(addr string) (*peerstore.PeerInfo, error) {
|
|
maddr, err := multiAddrFromString(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)
|
|
}
|