diff --git a/src/yggdrasil/api.go b/src/yggdrasil/api.go index 693dbd06..e2c3b97a 100644 --- a/src/yggdrasil/api.go +++ b/src/yggdrasil/api.go @@ -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 { diff --git a/src/yggdrasil/nodeinfo.go b/src/yggdrasil/nodeinfo.go index c3e9a274..fc6250d6 100644 --- a/src/yggdrasil/nodeinfo.go +++ b/src/yggdrasil/nodeinfo.go @@ -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) }) } diff --git a/src/yggdrasil/router.go b/src/yggdrasil/router.go index bd6eefdf..b08a12d3 100644 --- a/src/yggdrasil/router.go +++ b/src/yggdrasil/router.go @@ -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) } diff --git a/src/yggdrasil/search.go b/src/yggdrasil/search.go index 4708a705..92fc68b6 100644 --- a/src/yggdrasil/search.go +++ b/src/yggdrasil/search.go @@ -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.