From 79499b5cac7462788f79cb93c390d24b2c4f073d Mon Sep 17 00:00:00 2001 From: ddl Date: Tue, 16 Jan 2024 02:46:26 +0800 Subject: [PATCH] refactor(p2p/dnsdisc): replace strings.IndexByte with strings.Cut (#9236) similar to https://github.com/ledgerwatch/erigon/pull/9202 --- p2p/dnsdisc/tree.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/p2p/dnsdisc/tree.go b/p2p/dnsdisc/tree.go index 8329e6667..0c47edf94 100644 --- a/p2p/dnsdisc/tree.go +++ b/p2p/dnsdisc/tree.go @@ -311,11 +311,11 @@ func parseLink(e string) (*linkEntry, error) { return nil, fmt.Errorf("wrong/missing scheme 'enrtree' in URL") } e = e[len(linkPrefix):] - pos := strings.IndexByte(e, '@') - if pos == -1 { + keystring, domain, ok := strings.Cut(e, "@") + if !ok { return nil, entryError{"link", errNoPubkey} } - keystring, domain := e[:pos], e[pos+1:] + keybytes, err := b32format.DecodeString(keystring) if err != nil { return nil, entryError{"link", errBadPubkey}