mirror of https://github.com/status-im/go-waku.git
fix: extract multiaddress from enode key if available (#199)
This commit is contained in:
parent
f4f307db87
commit
cf6c4ae8fe
|
@ -362,22 +362,25 @@ func (d *DiscoveryV5) iterate(ctx context.Context, iterator enode.Iterator, limi
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
address, err := utils.EnodeToMultiAddr(iterator.Node())
|
addresses, err := utils.Multiaddress(iterator.Node())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.log.Error(err)
|
d.log.Error(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
peerInfo, err := peer.AddrInfoFromP2pAddr(address)
|
peerAddrs, err := peer.AddrInfosFromP2pAddrs(addresses...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.log.Error(err)
|
d.log.Error(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
d.peerCache.recs[peerInfo.ID] = peerRecord{
|
for _, p := range peerAddrs {
|
||||||
expire: time.Now().Unix() + 3600, // Expires in 1hr
|
d.peerCache.recs[p.ID] = peerRecord{
|
||||||
peer: *peerInfo,
|
expire: time.Now().Unix() + 3600, // Expires in 1hr
|
||||||
|
peer: p,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(doneCh)
|
close(doneCh)
|
||||||
|
|
|
@ -144,8 +144,13 @@ func Multiaddress(node *enode.Node) ([]ma.Multiaddr, error) {
|
||||||
|
|
||||||
var multiaddrRaw []byte
|
var multiaddrRaw []byte
|
||||||
if err := node.Record().Load(enr.WithEntry(MultiaddrENRField, &multiaddrRaw)); err != nil {
|
if err := node.Record().Load(enr.WithEntry(MultiaddrENRField, &multiaddrRaw)); err != nil {
|
||||||
if !enr.IsNotFound(err) {
|
if enr.IsNotFound(err) {
|
||||||
Logger().Error("could not retrieve multiaddress field for node ", zap.Any("enode", node))
|
Logger().Debug("Trying to convert enode to multiaddress, since I could not retrieve multiaddress field for node ", zap.Any("enode", node))
|
||||||
|
addr, err := EnodeToMultiAddr(node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return []ma.Multiaddr{addr}, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue