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
bea4ed78
Commit
bea4ed78
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(cmd/daemon) add --gcr option to run GCR routing client
parent
86455b81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
cmd/ipfs/daemon.go
cmd/ipfs/daemon.go
+26
-0
No files found.
cmd/ipfs/daemon.go
View file @
bea4ed78
...
...
@@ -10,6 +10,8 @@ import (
"github.com/jbenet/go-ipfs/core"
commands
"github.com/jbenet/go-ipfs/core/commands"
corehttp
"github.com/jbenet/go-ipfs/core/corehttp"
"github.com/jbenet/go-ipfs/core/corerouting"
peer
"github.com/jbenet/go-ipfs/p2p/peer"
fsrepo
"github.com/jbenet/go-ipfs/repo/fsrepo"
util
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/debugerror"
...
...
@@ -17,6 +19,7 @@ import (
const
(
initOptionKwd
=
"init"
gcrKwd
=
"gcr"
mountKwd
=
"mount"
writableKwd
=
"writable"
ipfsMountKwd
=
"mount-ipfs"
...
...
@@ -39,6 +42,7 @@ the daemon.
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
initOptionKwd
,
"Initialize IPFS with default settings if not already initialized"
),
cmds
.
BoolOption
(
gcrKwd
,
"Enables Grandcentral Routing"
),
cmds
.
BoolOption
(
mountKwd
,
"Mounts IPFS to the filesystem"
),
cmds
.
BoolOption
(
writableKwd
,
"Enable writing objects (with POST, PUT and DELETE)"
),
cmds
.
StringOption
(
ipfsMountKwd
,
"Path to the mountpoint for IPFS (if using --mount)"
),
...
...
@@ -103,6 +107,28 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
nb
:=
core
.
NewNodeBuilder
()
.
Online
()
nb
.
SetRepo
(
repo
)
useGCR
,
_
,
err
:=
req
.
Option
(
gcrKwd
)
.
Bool
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
if
useGCR
{
servers
,
err
:=
repo
.
Config
()
.
GCR
.
ServerIPFSAddrs
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
repo
.
Close
()
// because ownership hasn't been transferred to the node
return
}
var
infos
[]
peer
.
PeerInfo
for
_
,
addr
:=
range
servers
{
infos
=
append
(
infos
,
peer
.
PeerInfo
{
ID
:
addr
.
ID
(),
Addrs
:
[]
ma
.
Multiaddr
{
addr
.
Transport
()},
})
}
nb
.
SetRouting
(
corerouting
.
SupernodeClient
(
infos
...
))
}
node
,
err
:=
nb
.
Build
(
ctx
.
Context
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
...
...
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