This commit is contained in:
Jared Wasinger 2025-02-27 20:55:07 +01:00
parent beb451ee7f
commit 177b34114f

View file

@ -877,9 +877,9 @@ func readUntil[T any](ctx context.Context, conn *Conn) (*T, error) {
}
continue
}
switch received.(type) {
switch res := received.(type) {
case *T:
res := received.(*T)
return res, nil
}
}
@ -888,7 +888,8 @@ func readUntil[T any](ctx context.Context, conn *Conn) (*T, error) {
// readUntilDisconnect reads eth protocol messages until the peer disconnects.
// It returns whether the peer disconnects in the next 100ms.
func readUntilDisconnect(conn *Conn) (disconnected bool) {
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
_, err := readUntil[struct{}](ctx, conn)
return err == errDisc
}