mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
c35bdf2649
* refactors calls to deprecated IDB58Decode() * Merge branch 'master' into p2p-refactor-deprecated * updated packages * gazelle * mod tidy * refactors publish()/subscribe() deprecated methods * gofmt * test update join/leave topic methods * re-arrange imports * Merge branch 'master' into p2p-refactor-deprecated * Merge refs/heads/master into p2p-refactor-deprecated
32 lines
678 B
Go
32 lines
678 B
Go
package p2p
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/libp2p/go-libp2p-core/host"
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// MakePeer from multiaddress string.
|
|
func MakePeer(addr string) (*peer.AddrInfo, error) {
|
|
maddr, err := multiAddrFromString(addr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return peer.AddrInfoFromP2pAddr(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
|
|
}
|
|
ctx, cancel := context.WithTimeout(ctx, maxDialTimeout)
|
|
defer cancel()
|
|
return h.Connect(ctx, *p)
|
|
}
|