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/dnsdisc"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"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
|
// RetrieveNodes returns a list of multiaddress given a url to a DNS discoverable
|
||||||
// ENR tree
|
// ENR tree
|
||||||
func RetrieveNodes(url string) ([]string, error) {
|
func RetrieveNodes(url string) ([]ma.Multiaddr, error) {
|
||||||
var multiAddrs []string
|
var multiAddrs []ma.Multiaddr
|
||||||
|
|
||||||
client := dnsdisc.NewClient(dnsdisc.Config{})
|
client := dnsdisc.NewClient(dnsdisc.Config{})
|
||||||
|
|
||||||
|
@ -33,11 +35,11 @@ func RetrieveNodes(url string) ([]string, error) {
|
||||||
return multiAddrs, nil
|
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()})
|
peerID, err := peer.IDFromPublicKey(&ECDSAPublicKey{node.Pubkey()})
|
||||||
if err != nil {
|
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