mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
p2p/discv5: remove unnecessary ping before topic query
This commit is contained in:
parent
8144830e92
commit
f303cc5467
3 changed files with 5 additions and 8 deletions
|
|
@ -565,10 +565,7 @@ loop:
|
||||||
if lookupChn := searchInfo[res.target.topic].lookupChn; lookupChn != nil {
|
if lookupChn := searchInfo[res.target.topic].lookupChn; lookupChn != nil {
|
||||||
lookupChn <- net.ticketStore.radius[res.target.topic].converged
|
lookupChn <- net.ticketStore.radius[res.target.topic].converged
|
||||||
}
|
}
|
||||||
net.ticketStore.searchLookupDone(res.target, res.nodes, func(n *Node) []byte {
|
net.ticketStore.searchLookupDone(res.target, res.nodes, func(n *Node, topic Topic) []byte {
|
||||||
net.ping(n, n.addr())
|
|
||||||
return n.pingEcho
|
|
||||||
}, func(n *Node, topic Topic) []byte {
|
|
||||||
if n.canQuery() {
|
if n.canQuery() {
|
||||||
return net.conn.send(n, topicQueryPacket, topicQuery{Topic: topic}) // TODO: set expiration
|
return net.conn.send(n, topicQueryPacket, topicQuery{Topic: topic}) // TODO: set expiration
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1088,7 +1085,7 @@ func (net *Network) transition(n *Node, next *nodeState) {
|
||||||
if n.state != next {
|
if n.state != next {
|
||||||
if next.canQuery {
|
if next.canQuery {
|
||||||
if !n.state.canQuery {
|
if !n.state.canQuery {
|
||||||
n.canQueryAfter = mclock.Now()+mclock.AbsTime(time.Second)
|
n.canQueryAfter = mclock.Now()+mclock.AbsTime(queryDelay)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
n.canQueryAfter = 0
|
n.canQueryAfter = 0
|
||||||
|
|
|
||||||
|
|
@ -494,13 +494,13 @@ func (s *ticketStore) registerLookupDone(lookup lookupInfo, nodes []*Node, ping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ticketStore) searchLookupDone(lookup lookupInfo, nodes []*Node, ping func(n *Node) []byte, query func(n *Node, topic Topic) []byte) {
|
func (s *ticketStore) searchLookupDone(lookup lookupInfo, nodes []*Node, query func(n *Node, topic Topic) []byte) {
|
||||||
now := mclock.Now()
|
now := mclock.Now()
|
||||||
for i, n := range nodes {
|
for i, n := range nodes {
|
||||||
if i == 0 || (binary.BigEndian.Uint64(n.sha[:8])^binary.BigEndian.Uint64(lookup.target[:8])) < s.radius[lookup.topic].minRadius {
|
if i == 0 || (binary.BigEndian.Uint64(n.sha[:8])^binary.BigEndian.Uint64(lookup.target[:8])) < s.radius[lookup.topic].minRadius {
|
||||||
if lookup.radiusLookup {
|
if lookup.radiusLookup {
|
||||||
if lastReq, ok := s.nodeLastReq[n]; !ok || time.Duration(now-lastReq.time) > radiusTC {
|
if lastReq, ok := s.nodeLastReq[n]; !ok || time.Duration(now-lastReq.time) > radiusTC {
|
||||||
s.nodeLastReq[n] = reqInfo{pingHash: ping(n), lookup: lookup, time: now}
|
s.nodeLastReq[n] = reqInfo{pingHash: nil, lookup: lookup, time: now}
|
||||||
}
|
}
|
||||||
} // else {
|
} // else {
|
||||||
if s.canQueryTopic(n, lookup.topic) {
|
if s.canQueryTopic(n, lookup.topic) {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ var (
|
||||||
// Timeouts
|
// Timeouts
|
||||||
const (
|
const (
|
||||||
respTimeout = 500 * time.Millisecond
|
respTimeout = 500 * time.Millisecond
|
||||||
sendTimeout = 500 * time.Millisecond
|
queryDelay = 1000 * time.Millisecond
|
||||||
expiration = 20 * time.Second
|
expiration = 20 * time.Second
|
||||||
|
|
||||||
ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP
|
ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue