mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
6bea17cb54
* Update libp2p to support go 1.19 * gaz * go mod tidy * Only update the minimum deps * go mod tidy * revert .bazelrc * Update go-libp2p to v0.22.0 and update import paths (#11440) * Fix import paths * Fix go-libp2p-peerstore import * Bazel updates * fix * revert some comments changes * revert some comment stuff * fix dependency issues * vendor problematic library * use your brain * remove * tests Co-authored-by: Marco Munizaga <marco@marcopolo.io> Co-authored-by: Nishant Das <nishdas93@gmail.com>
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)
|
|
}
|