fix: invalid length of multiaddr field (but loaded succesfully anyway)

This commit is contained in:
Richard Ramos 2023-02-13 09:33:41 -04:00
parent 11161b8919
commit 78520e9280
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
1 changed files with 6 additions and 1 deletions

View File

@ -75,12 +75,17 @@ func Multiaddress(node *enode.Node) ([]multiaddr.Multiaddr, error) {
if err := node.Record().Load(enr.WithEntry(MultiaddrENRField, &multiaddrRaw)); err != nil {
if !enr.IsNotFound(err) {
return nil, err
} else if len(multiaddrRaw) < 2 {
} else {
// No multiaddr entry on enr
return result, nil
}
}
if len(multiaddrRaw) < 2 {
// There was no error loading the multiaddr field, but its length is incorrect
return result, nil
}
hostInfo, err := multiaddr.NewMultiaddr(fmt.Sprintf("/p2p/%s", peerID.Pretty()))
if err != nil {
return nil, err