mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 03:31:20 +00:00
100ca0ebaf
* first * attempt p2p connect send tool * attempt * stream registration * trying to register * attempt * workinnnn * begin * p2p prysmctl tool * ignore * fix * delete deprecated * p2p smaller iface surface area * further p2p refactor * gaz * better logging * process * all functionality * fix up * rhandle * v2 req * cmd * send sub * v1 handle * show head slot * cmd * cmd lib * gazelle fix * bazel * gaz * work on the handshake items * prevent dial to self * add config awareness * gaz * inferring host addrs from p2p * initialize data mappings * add own mock * fix up logic * gaz * add img * gaz * add images * builds * builds * nishant feedback: Co-authored-by: Nishant Das <nishdas93@gmail.com>
29 lines
564 B
Go
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
|
|
}
|