mirror of https://github.com/status-im/go-waku.git
fix: use multiaddres instead of strings
This commit is contained in:
parent
cfcfb52a58
commit
9416077adf
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue