Skip to content

Commit

Permalink
convertToMultiAddrs ==> retrieveMultiAddrsFromNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
nalepae committed Apr 4, 2024
1 parent a26fb88 commit a0c0326
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions beacon-chain/p2p/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func PeersFromStringAddrs(addrs []string) ([]ma.Multiaddr, error) {
if err != nil {
return nil, errors.Wrapf(err, "Could not get enode from string")
}
nodeAddrs, err := convertToMultiAddrs(enodeAddr)
nodeAddrs, err := retrieveMultiAddrsFromNode(enodeAddr)
if err != nil {
return nil, errors.Wrapf(err, "Could not get multiaddr")
}
Expand Down Expand Up @@ -449,7 +449,7 @@ func convertToMultiAddr(nodes []*enode.Node) []ma.Multiaddr {
}

// Get up to two multiaddrs (TCP and QUIC) for each node.
nodeMultiAddrs, err := convertToMultiAddrs(node)
nodeMultiAddrs, err := retrieveMultiAddrsFromNode(node)
if err != nil {
log.WithError(err).Errorf("Could not convert to multiAddr node %s", node)
continue
Expand All @@ -462,7 +462,7 @@ func convertToMultiAddr(nodes []*enode.Node) []ma.Multiaddr {
}

func convertToAddrInfo(node *enode.Node) (*peer.AddrInfo, []ma.Multiaddr, error) {
multiAddrs, err := convertToMultiAddrs(node)
multiAddrs, err := retrieveMultiAddrsFromNode(node)
if err != nil {
return nil, nil, err
}
Expand All @@ -487,11 +487,11 @@ func convertToAddrInfo(node *enode.Node) (*peer.AddrInfo, []ma.Multiaddr, error)
return &infos[0], multiAddrs, nil
}

// convertToMultiAddrs converts an enode.Node to a list of multiaddrs.
// retrieveMultiAddrsFromNode converts an enode.Node to a list of multiaddrs.
// If the node has a both a QUIC and a TCP port set in their ENR, then
// the multiaddr corresponding to the QUIC port is added first, followed
// by the multiaddr corresponding to the TCP port.
func convertToMultiAddrs(node *enode.Node) ([]ma.Multiaddr, error) {
func retrieveMultiAddrsFromNode(node *enode.Node) ([]ma.Multiaddr, error) {
multiaddrs := make([]ma.Multiaddr, 0, 2)

// Retrieve the node public key.
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/p2p/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestStartDiscv5_DifferentForkDigests(t *testing.T) {

for _, node := range nodes {
if s.filterPeer(node) {
nodeAddrs, err := convertToMultiAddrs(node)
nodeAddrs, err := retrieveMultiAddrsFromNode(node)
require.NoError(t, err)
addrs = append(addrs, nodeAddrs...)
}
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestStartDiscv5_SameForkDigests_DifferentNextForkData(t *testing.T) {

for _, node := range nodes {
if s.filterPeer(node) {
nodeAddrs, err := convertToMultiAddrs(node)
nodeAddrs, err := retrieveMultiAddrsFromNode(node)
require.NoError(t, err)
addrs = append(addrs, nodeAddrs...)
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/p2p/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestIPV6Support(t *testing.T) {
lNode := enode.NewLocalNode(db, key)
mockIPV6 := net.IP{0xff, 0x02, 0xAA, 0, 0x1F, 0, 0x2E, 0, 0, 0x36, 0x45, 0, 0, 0, 0, 0x02}
lNode.Set(enr.IP(mockIPV6))
mas, err := convertToMultiAddrs(lNode.Node())
mas, err := retrieveMultiAddrsFromNode(lNode.Node())
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit a0c0326

Please sign in to comment.