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-unixfs
Commits
ddf14bee
Commit
ddf14bee
authored
Jan 10, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(core): replace online bool with mode type
parent
130532c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
7 deletions
+26
-7
core/core.go
core/core.go
+26
-7
No files found.
core/core.go
View file @
ddf14bee
...
...
@@ -17,7 +17,7 @@ import (
exchange
"github.com/jbenet/go-ipfs/exchange"
bitswap
"github.com/jbenet/go-ipfs/exchange/bitswap"
bsnet
"github.com/jbenet/go-ipfs/exchange/bitswap/network"
"github.com/jbenet/go-ipfs/exchange/offline"
offline
"github.com/jbenet/go-ipfs/exchange/offline"
mount
"github.com/jbenet/go-ipfs/fuse/mount"
importer
"github.com/jbenet/go-ipfs/importer"
chunk
"github.com/jbenet/go-ipfs/importer/chunk"
...
...
@@ -45,12 +45,20 @@ const kSizeBlockstoreWriteCache = 100
var
log
=
eventlog
.
Logger
(
"core"
)
type
mode
int
const
(
// zero value is not a valid mode, must be explicitly set
invalidMode
mode
=
iota
offlineMode
onlineMode
)
// IpfsNode is IPFS Core module. It represents an IPFS instance.
type
IpfsNode
struct
{
// Self
Identity
peer
.
ID
// the local node's identity
onlineMode
bool
// alternatively, offline
Identity
peer
.
ID
// the local node's identity
// TODO abstract as repo.Repo
Config
*
config
.
Config
// the node's configuration
...
...
@@ -80,7 +88,8 @@ type IpfsNode struct {
// dht allows node to Bootstrap when dht is present
// TODO privatize before merging. This is here temporarily during the
// migration of the TestNet constructor
DHT
*
dht
.
IpfsDHT
DHT
*
dht
.
IpfsDHT
mode
mode
}
// Mounts defines what the node's mount state is. This should
...
...
@@ -142,8 +151,13 @@ func Standard(cfg *config.Config, online bool) ConfigOption {
return
nil
,
debugerror
.
Errorf
(
"configuration required"
)
}
n
=
&
IpfsNode
{
onlineMode
:
online
,
Config
:
cfg
,
mode
:
func
()
mode
{
if
online
{
return
onlineMode
}
return
offlineMode
}(),
Config
:
cfg
,
}
n
.
ContextGroup
=
ctxgroup
.
WithContextAndTeardown
(
ctx
,
n
.
teardown
)
...
...
@@ -247,7 +261,12 @@ func (n *IpfsNode) teardown() error {
}
func
(
n
*
IpfsNode
)
OnlineMode
()
bool
{
return
n
.
onlineMode
switch
n
.
mode
{
case
onlineMode
:
return
true
default
:
return
false
}
}
func
(
n
*
IpfsNode
)
Bootstrap
(
ctx
context
.
Context
,
peers
[]
peer
.
PeerInfo
)
error
{
...
...
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