Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
c9896467
Commit
c9896467
authored
Jan 30, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refac(gcr/s,c) use PeerRoutingInfo
parent
0db1a948
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
routing/grandcentral/client.go
routing/grandcentral/client.go
+10
-3
routing/grandcentral/server.go
routing/grandcentral/server.go
+14
-2
No files found.
routing/grandcentral/client.go
View file @
c9896467
...
...
@@ -80,9 +80,16 @@ 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
return
c
.
proxy
.
SendMessage
(
ctx
,
msg
)
// TODO wrap to hide remote
// 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
}
func
(
c
*
Client
)
FindPeer
(
ctx
context
.
Context
,
id
peer
.
ID
)
(
peer
.
PeerInfo
,
error
)
{
...
...
routing/grandcentral/server.go
View file @
c9896467
...
...
@@ -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
()})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment