prysm-pulse/cmd/prysmctl/p2p/peers.go
Preston Van Loon 6bea17cb54
Update libp2p to support go 1.19 (#11309)
* 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>
2022-10-07 15:24:51 +08:00

29 lines
564 B
Go

package p2p
import (
"context"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p"
)
func (c *client) connectToPeers(ctx context.Context, peerMultiaddrs ...string) error {
peers, err := p2p.PeersFromStringAddrs(peerMultiaddrs)
if err != nil {
return err
}
addrInfos, err := peer.AddrInfosFromP2pAddrs(peers...)
if err != nil {
panic(err)
}
for _, info := range addrInfos {
if info.ID == c.host.ID() {
continue
}
if err := c.host.Connect(ctx, info); err != nil {
return err
}
}
return nil
}