mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
p2p/discv5: remove canQuery()
This commit is contained in:
parent
19de3bc61f
commit
05328a40a4
1 changed files with 2 additions and 14 deletions
|
|
@ -566,7 +566,7 @@ loop:
|
||||||
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, topic Topic) []byte {
|
net.ticketStore.searchLookupDone(res.target, res.nodes, func(n *Node, topic Topic) []byte {
|
||||||
if n.canQuery() {
|
if n.state != nil && n.state.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 {
|
||||||
if n.state == unknown {
|
if n.state == unknown {
|
||||||
|
|
@ -783,11 +783,6 @@ type nodeNetGuts struct {
|
||||||
deferredQueries []*findnodeQuery // queries that can't be sent yet
|
deferredQueries []*findnodeQuery // queries that can't be sent yet
|
||||||
pendingNeighbours *findnodeQuery // current query, waiting for reply
|
pendingNeighbours *findnodeQuery // current query, waiting for reply
|
||||||
queryTimeouts int
|
queryTimeouts int
|
||||||
canQueryAfter mclock.AbsTime // cannot query if zero
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *nodeNetGuts) canQuery() bool {
|
|
||||||
return n.canQueryAfter != 0 && mclock.Now() > n.canQueryAfter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nodeNetGuts) deferQuery(q *findnodeQuery) {
|
func (n *nodeNetGuts) deferQuery(q *findnodeQuery) {
|
||||||
|
|
@ -811,7 +806,7 @@ func (q *findnodeQuery) start(net *Network) bool {
|
||||||
q.reply <- closest.entries
|
q.reply <- closest.entries
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if q.remote.canQuery() && q.remote.pendingNeighbours == nil {
|
if q.remote.state.canQuery && q.remote.pendingNeighbours == nil {
|
||||||
net.conn.sendFindnodeHash(q.remote, q.target)
|
net.conn.sendFindnodeHash(q.remote, q.target)
|
||||||
net.timedEvent(respTimeout, q.remote, neighboursTimeout)
|
net.timedEvent(respTimeout, q.remote, neighboursTimeout)
|
||||||
q.remote.pendingNeighbours = q
|
q.remote.pendingNeighbours = q
|
||||||
|
|
@ -1083,13 +1078,6 @@ func (net *Network) checkPacket(n *Node, ev nodeEvent, pkt *ingressPacket) error
|
||||||
|
|
||||||
func (net *Network) transition(n *Node, next *nodeState) {
|
func (net *Network) transition(n *Node, next *nodeState) {
|
||||||
if n.state != next {
|
if n.state != next {
|
||||||
if next.canQuery {
|
|
||||||
if !n.state.canQuery {
|
|
||||||
n.canQueryAfter = mclock.Now()+mclock.AbsTime(queryDelay)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
n.canQueryAfter = 0
|
|
||||||
}
|
|
||||||
n.state = next
|
n.state = next
|
||||||
if next.enter != nil {
|
if next.enter != nil {
|
||||||
next.enter(net, n)
|
next.enter(net, n)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue