Commit c9896467 authored by Brian Tiger Chow's avatar Brian Tiger Chow

refac(gcr/s,c) use PeerRoutingInfo

parent 0db1a948
......@@ -80,8 +80,15 @@ func (c *Client) GetValue(ctx context.Context, k u.Key) ([]byte, error) {
func (c *Client) Provide(ctx context.Context, k u.Key) error {
msg := pb.NewMessage(pb.Message_ADD_PROVIDER, string(k), 0)
// TODO wrap this to hide the dialer and the local/remote peers
msg.ProviderPeers = pb.PeerInfosToPBPeers(c.dialer, []peer.PeerInfo{peer.PeerInfo{ID: c.local}}) // FIXME how is connectedness defined for the local node
// FIXME how is connectedness defined for the local node
pri := []pb.PeerRoutingInfo{
pb.PeerRoutingInfo{
PeerInfo: peer.PeerInfo{
ID: c.local,
},
},
}
msg.ProviderPeers = pb.PeerRoutingInfosToPBPeers(pri)
return c.proxy.SendMessage(ctx, msg) // TODO wrap to hide remote
}
......
......@@ -84,7 +84,13 @@ func (s *Server) handleMessage(
case dhtpb.Message_FIND_NODE:
p := s.peerstore.PeerInfo(peer.ID(req.GetKey()))
response.CloserPeers = dhtpb.PeerInfosToPBPeers(s.dialer, []peer.PeerInfo{p})
pri := []dhtpb.PeerRoutingInfo{
dhtpb.PeerRoutingInfo{
PeerInfo: p,
// Connectedness: TODO
},
}
response.CloserPeers = dhtpb.PeerRoutingInfosToPBPeers(pri)
return p.ID, response
case dhtpb.Message_ADD_PROVIDER:
......@@ -116,7 +122,13 @@ func (s *Server) handleMessage(
dskey := util.Key(req.GetKey()).DsKey()
exists, err := s.datastore.Has(dskey)
if err == nil && exists {
response.ProviderPeers = append(response.ProviderPeers, dhtpb.PeerInfosToPBPeers(s.dialer, []peer.PeerInfo{peer.PeerInfo{ID: s.local}})...)
pri := []dhtpb.PeerRoutingInfo{
dhtpb.PeerRoutingInfo{
// Connectedness: TODO how is connectedness defined for the local node
PeerInfo: peer.PeerInfo{ID: s.local},
},
}
response.ProviderPeers = append(response.ProviderPeers, dhtpb.PeerRoutingInfosToPBPeers(pri)...)
}
// FIXME(btc) is this how we want to persist this data?
pkey := datastore.KeyWithNamespaces([]string{"routing", "providers", req.GetKey()})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment