p2p/discover: bump v5 RPC timeout

This commit is contained in:
Felix Lange 2020-03-08 19:58:32 +01:00
parent a8297b4a5a
commit d8f15ab2f1

View file

@ -27,6 +27,7 @@ import (
"math" "math"
"net" "net"
"sync" "sync"
"time"
"github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -40,6 +41,8 @@ const (
findnodeResultLimit = 15 // applies in FINDNODE handler findnodeResultLimit = 15 // applies in FINDNODE handler
totalNodesResponseLimit = 5 // applies in waitForNodes totalNodesResponseLimit = 5 // applies in waitForNodes
nodesResponseItemLimit = 3 // applies in sendNodes nodesResponseItemLimit = 3 // applies in sendNodes
respTimeoutV5 = 700 * time.Millisecond
) )
// codecV5 is implemented by wireCodec (and testCodec). // codecV5 is implemented by wireCodec (and testCodec).
@ -107,10 +110,11 @@ type callV5 struct {
reqid []byte reqid []byte
ch chan packetV5 // responses sent here ch chan packetV5 // responses sent here
err chan error // errors sent here err chan error // errors sent here
// Valid for active calls only: // Valid for active calls only:
authTag []byte authTag []byte // authTag of request packet
handshakeCount int handshakeCount int // # times we attempted handshake for this call
challenge *whoareyouV5 challenge *whoareyouV5 // last sent handshake challenge
timeout mclock.Timer timeout mclock.Timer
} }
@ -493,7 +497,7 @@ func (t *UDPv5) startResponseTimeout(c *callV5) {
timer mclock.Timer timer mclock.Timer
done = make(chan struct{}) done = make(chan struct{})
) )
timer = t.clock.AfterFunc(respTimeout, func() { timer = t.clock.AfterFunc(respTimeoutV5, func() {
<-done <-done
select { select {
case t.respTimeoutCh <- &callTimeout{c, timer}: case t.respTimeoutCh <- &callTimeout{c, timer}: