public ActionResult GetNodesRaw(string nodeid) { var nodes = GetNodes(nodeid); if (nodes != null) { var key = _node.NodeConfiguration.LocaleNodePrivateKey; var m = new KademliaQueryResultMessage { Nodes = nodes, SignKey = key }; return(File(m.ToByteArray(), "application/octet-stream", "result.data")); } return(BadRequestJson()); }
Task OnQueryResult(KademliaQueryResultMessage message, Connection connection, NodeInfo nodeInfo) { if (Log.LogTrace) { Log.Trace($"Kademlia QueryResult received from: {nodeInfo.PublicEndPoint}", this); } lock (_lock) { _queryNodes.Add(nodeInfo); foreach (var node in message.Nodes) { _queryNodes.Add(node); } } return(Task.CompletedTask); }
async Task OnQuery(KademliaQueryMessage message, Connection connection, NodeInfo nodeInfo) { if (Log.LogTrace) { Log.Trace($"Kademlia Query received from: {nodeInfo.PublicEndPoint}", this); } lock (_lock) _queryNodes.Add(nodeInfo); var nodes = _bucket.GetNearNodes(nodeInfo.NodeId); var resultMessage = new KademliaQueryResultMessage { SignKey = LocalKey }; foreach (var node in nodes) { resultMessage.Nodes.Add(node); } await connection.Send(resultMessage); }