From 9416077adfb203aaf368253611dc44297cb7391f Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Mon, 27 Sep 2021 14:16:06 -0400 Subject: [PATCH] fix: use multiaddres instead of strings --- waku/v2/discovery/enr.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/waku/v2/discovery/enr.go b/waku/v2/discovery/enr.go index 81ff18e2..512035b0 100644 --- a/waku/v2/discovery/enr.go +++ b/waku/v2/discovery/enr.go @@ -6,12 +6,14 @@ import ( "github.com/ethereum/go-ethereum/p2p/dnsdisc" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/libp2p/go-libp2p-core/peer" + + ma "github.com/multiformats/go-multiaddr" ) // RetrieveNodes returns a list of multiaddress given a url to a DNS discoverable // ENR tree -func RetrieveNodes(url string) ([]string, error) { - var multiAddrs []string +func RetrieveNodes(url string) ([]ma.Multiaddr, error) { + var multiAddrs []ma.Multiaddr client := dnsdisc.NewClient(dnsdisc.Config{}) @@ -33,11 +35,11 @@ func RetrieveNodes(url string) ([]string, error) { return multiAddrs, nil } -func enodeToMultiAddr(node *enode.Node) (string, error) { +func enodeToMultiAddr(node *enode.Node) (ma.Multiaddr, error) { peerID, err := peer.IDFromPublicKey(&ECDSAPublicKey{node.Pubkey()}) if err != nil { - return "", err + return nil, err } - return fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", node.IP(), node.TCP(), peerID), nil + return ma.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", node.IP(), node.TCP(), peerID)) }