mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-25 23:01:38 +00:00
some nodeinfo actor fixes and adjust search timeout
This commit is contained in:
parent
8c12fc4fdb
commit
c3b1a6af65
@ -398,6 +398,7 @@ func (c *Core) GetNodeInfo(key crypto.BoxPubKey, coords []uint64, nocache bool)
|
||||
}
|
||||
})
|
||||
c.router.nodeinfo.sendNodeInfo(key, wire_coordsUint64stoBytes(coords), false)
|
||||
phony.Block(&c.router.nodeinfo, func() {}) // Wait for sendNodeInfo before starting timer
|
||||
timer := time.AfterFunc(6*time.Second, func() { close(response) })
|
||||
defer timer.Stop()
|
||||
for res := range response {
|
||||
|
@ -41,7 +41,7 @@ type nodeinfoReqRes struct {
|
||||
// Initialises the nodeinfo cache/callback maps, and starts a goroutine to keep
|
||||
// the cache/callback maps clean of stale entries
|
||||
func (m *nodeinfo) init(core *Core) {
|
||||
m.Act(m, func() {
|
||||
m.Act(nil, func() {
|
||||
m._init(core)
|
||||
})
|
||||
}
|
||||
@ -66,13 +66,13 @@ func (m *nodeinfo) _cleanup() {
|
||||
}
|
||||
}
|
||||
time.AfterFunc(time.Second*30, func() {
|
||||
m.Act(m, m._cleanup)
|
||||
m.Act(nil, m._cleanup)
|
||||
})
|
||||
}
|
||||
|
||||
// Add a callback for a nodeinfo lookup
|
||||
func (m *nodeinfo) addCallback(sender crypto.BoxPubKey, call func(nodeinfo *NodeInfoPayload)) {
|
||||
m.Act(m, func() {
|
||||
m.Act(nil, func() {
|
||||
m._addCallback(sender, call)
|
||||
})
|
||||
}
|
||||
@ -164,8 +164,8 @@ func (m *nodeinfo) _getCachedNodeInfo(key crypto.BoxPubKey) (NodeInfoPayload, er
|
||||
}
|
||||
|
||||
// Handles a nodeinfo request/response - called from the router
|
||||
func (m *nodeinfo) handleNodeInfo(nodeinfo *nodeinfoReqRes) {
|
||||
m.Act(m, func() {
|
||||
func (m *nodeinfo) handleNodeInfo(from phony.Actor, nodeinfo *nodeinfoReqRes) {
|
||||
m.Act(from, func() {
|
||||
m._handleNodeInfo(nodeinfo)
|
||||
})
|
||||
}
|
||||
@ -181,7 +181,7 @@ func (m *nodeinfo) _handleNodeInfo(nodeinfo *nodeinfoReqRes) {
|
||||
|
||||
// Send nodeinfo request or response - called from the router
|
||||
func (m *nodeinfo) sendNodeInfo(key crypto.BoxPubKey, coords []byte, isResponse bool) {
|
||||
m.Act(m, func() {
|
||||
m.Act(nil, func() {
|
||||
m._sendNodeInfo(key, coords, isResponse)
|
||||
})
|
||||
}
|
||||
|
@ -250,5 +250,5 @@ func (r *router) _handleNodeInfo(bs []byte, fromKey *crypto.BoxPubKey) {
|
||||
return
|
||||
}
|
||||
req.SendPermPub = *fromKey
|
||||
r.nodeinfo.handleNodeInfo(&req)
|
||||
r.nodeinfo.handleNodeInfo(r, &req)
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ import (
|
||||
// This defines the maximum number of dhtInfo that we keep track of for nodes to query in an ongoing search.
|
||||
const search_MAX_SEARCH_SIZE = 16
|
||||
|
||||
// This defines the time after which we send a new search packet.
|
||||
// Search packets are sent automatically immediately after a response is received.
|
||||
// So this allows for timeouts and for long searches to become increasingly parallel.
|
||||
const search_RETRY_TIME = time.Second
|
||||
// This defines the time after which we time out a search (so it can restart).
|
||||
const search_RETRY_TIME = 3 * time.Second
|
||||
|
||||
// Information about an ongoing search.
|
||||
// Includes the target NodeID, the bitmask to match it to an IP, and the list of nodes to visit / already visited.
|
||||
|
Loading…
Reference in New Issue
Block a user