p2p: use errors.Is for error comparison (#24882)

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Håvard Anda Estensen
2022-06-07 17:27:21 +02:00
committed by GitHub
co-authored by Felix Lange
parent 41e75480df
commit 138f0d7494
9 changed files with 24 additions and 13 deletions
+3 -2
View File
@@ -19,6 +19,7 @@ package dnsdisc
import (
"bytes"
"context"
"errors"
"fmt"
"math/rand"
"net"
@@ -204,7 +205,7 @@ func (c *Client) doResolveEntry(ctx context.Context, domain, hash string) (entry
}
for _, txt := range txts {
e, err := parseEntry(txt, c.cfg.ValidSchemes)
if err == errUnknownEntry {
if errors.Is(err, errUnknownEntry) {
continue
}
if !bytes.HasPrefix(crypto.Keccak256([]byte(txt)), wantHash) {
@@ -281,7 +282,7 @@ func (it *randomIterator) nextNode() *enode.Node {
}
n, err := ct.syncRandom(it.ctx)
if err != nil {
if err == it.ctx.Err() {
if errors.Is(err, it.ctx.Err()) {
return nil // context canceled.
}
it.c.cfg.Logger.Debug("Error in DNS random node sync", "tree", ct.loc.domain, "err", err)