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
9e5b3b77
Commit
9e5b3b77
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(gcr/c) pass host.Host into GCR client
parent
ea9ea794
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
core/corerouting/core.go
core/corerouting/core.go
+5
-2
routing/grandcentral/client.go
routing/grandcentral/client.go
+6
-2
No files found.
core/corerouting/core.go
View file @
9e5b3b77
...
...
@@ -29,6 +29,9 @@ func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.Routing
if
node
.
Peerstore
==
nil
{
return
nil
,
errPeerstoreMissing
}
if
node
.
PeerHost
==
nil
{
return
nil
,
errHostMissing
}
if
node
.
Identity
==
""
{
return
nil
,
errIdentityMissing
}
...
...
@@ -41,7 +44,7 @@ func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.Routing
Local
:
node
.
Identity
,
}
node
.
PeerHost
.
SetStreamHandler
(
gcproxy
.
ProtocolGCR
,
proxy
.
HandleStream
)
return
grandcentral
.
NewClient
(
proxy
,
node
.
Peerstore
,
node
.
Identity
)
return
grandcentral
.
NewClient
(
proxy
,
node
.
PeerHost
,
node
.
Peerstore
,
node
.
Identity
)
}
}
...
...
@@ -77,6 +80,6 @@ func GrandCentralClient(remotes ...peer.PeerInfo) core.RoutingOption {
}
proxy
:=
gcproxy
.
Standard
(
node
.
PeerHost
,
ids
)
node
.
PeerHost
.
SetStreamHandler
(
gcproxy
.
ProtocolGCR
,
proxy
.
HandleStream
)
return
grandcentral
.
NewClient
(
proxy
,
node
.
Peerstore
,
node
.
Identity
)
return
grandcentral
.
NewClient
(
proxy
,
node
.
PeerHost
,
node
.
Peerstore
,
node
.
Identity
)
}
}
This diff is collapsed.
Click to expand it.
routing/grandcentral/client.go
View file @
9e5b3b77
...
...
@@ -6,6 +6,7 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
proto
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
"github.com/jbenet/go-ipfs/p2p/host"
peer
"github.com/jbenet/go-ipfs/p2p/peer"
routing
"github.com/jbenet/go-ipfs/routing"
pb
"github.com/jbenet/go-ipfs/routing/dht/pb"
...
...
@@ -18,17 +19,19 @@ import (
var
log
=
eventlog
.
Logger
(
"grandcentral"
)
type
Client
struct
{
peerhost
host
.
Host
peerstore
peer
.
Peerstore
proxy
proxy
.
Proxy
local
peer
.
ID
}
// TODO take in datastore/cache
func
NewClient
(
px
proxy
.
Proxy
,
ps
peer
.
Peerstore
,
local
peer
.
ID
)
(
*
Client
,
error
)
{
func
NewClient
(
px
proxy
.
Proxy
,
h
host
.
Host
,
ps
peer
.
Peerstore
,
local
peer
.
ID
)
(
*
Client
,
error
)
{
return
&
Client
{
proxy
:
px
,
local
:
local
,
peerstore
:
ps
,
peerhost
:
h
,
},
nil
}
...
...
@@ -79,7 +82,8 @@ func (c *Client) Provide(ctx context.Context, k u.Key) error {
pri
:=
[]
pb
.
PeerRoutingInfo
{
pb
.
PeerRoutingInfo
{
PeerInfo
:
peer
.
PeerInfo
{
ID
:
c
.
local
,
ID
:
c
.
local
,
Addrs
:
c
.
peerhost
.
Addrs
(),
},
},
}
...
...
This diff is collapsed.
Click to expand it.
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