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 continue
} }
switch received.(type) {
switch res := received.(type) {
case *T: case *T:
res := received.(*T)
return res, nil 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. // readUntilDisconnect reads eth protocol messages until the peer disconnects.
// It returns whether the peer disconnects in the next 100ms. // It returns whether the peer disconnects in the next 100ms.
func readUntilDisconnect(conn *Conn) (disconnected bool) { 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) _, err := readUntil[struct{}](ctx, conn)
return err == errDisc return err == errDisc
} }