FindNeighbor RPC returns FindNeighborReq.Count closest node from DHT.
(req *proto.FindNeighborReq, resp *proto.FindNeighborResp)
| 75 | |
| 76 | // FindNeighbor RPC returns FindNeighborReq.Count closest node from DHT. |
| 77 | func (DHT *DHTService) FindNeighbor(req *proto.FindNeighborReq, resp *proto.FindNeighborResp) (err error) { |
| 78 | if permissionCheckFunc != nil && !permissionCheckFunc(&req.Envelope, DHTFindNeighbor) { |
| 79 | err = fmt.Errorf("calling from node %s is not permitted", req.GetNodeID()) |
| 80 | log.Error(err) |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | nodes, err := DHT.Consistent.GetNeighborsEx(string(req.ID), req.Count, req.Roles) |
| 85 | if err != nil { |
| 86 | err = fmt.Errorf("get nodes from DHT failed: %s", err) |
| 87 | log.Error(err) |
| 88 | return |
| 89 | } |
| 90 | resp.Nodes = nodes |
| 91 | log.WithFields(log.Fields{ |
| 92 | "neighCount": len(nodes), |
| 93 | "req": req, |
| 94 | }).Debug("found nodes for find neighbor request") |
| 95 | return |
| 96 | } |
| 97 | |
| 98 | // Ping RPC adds PingReq.Node to DHT. |
| 99 | func (DHT *DHTService) Ping(req *proto.PingReq, resp *proto.PingResp) (err error) { |
nothing calls this directly
no test coverage detected