mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 11:31:02 +00:00
p2p/discover: swap verification order in discv4 ping handler (#27532)
In all other UDPv4 methods, the deadline is checked first. It seems weird to me that ping is an exception. Deadline comparison is also less resource intensive. Co-authored-by: Exca-DK <Exca-DK@users.noreply.github.com>
This commit is contained in:
parent
fd5d2ef0a6
commit
5520cd97a1
@ -643,13 +643,13 @@ type packetHandlerV4 struct {
|
|||||||
func (t *UDPv4) verifyPing(h *packetHandlerV4, from *net.UDPAddr, fromID enode.ID, fromKey v4wire.Pubkey) error {
|
func (t *UDPv4) verifyPing(h *packetHandlerV4, from *net.UDPAddr, fromID enode.ID, fromKey v4wire.Pubkey) error {
|
||||||
req := h.Packet.(*v4wire.Ping)
|
req := h.Packet.(*v4wire.Ping)
|
||||||
|
|
||||||
|
if v4wire.Expired(req.Expiration) {
|
||||||
|
return errExpired
|
||||||
|
}
|
||||||
senderKey, err := v4wire.DecodePubkey(crypto.S256(), fromKey)
|
senderKey, err := v4wire.DecodePubkey(crypto.S256(), fromKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if v4wire.Expired(req.Expiration) {
|
|
||||||
return errExpired
|
|
||||||
}
|
|
||||||
h.senderKey = senderKey
|
h.senderKey = senderKey
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user