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
4c2eda21
Commit
4c2eda21
authored
Jan 10, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove deprecated function
parent
57b3ffa5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
57 deletions
+50
-57
core/core.go
core/core.go
+50
-57
No files found.
core/core.go
View file @
4c2eda21
...
...
@@ -78,9 +78,7 @@ type Mounts struct {
var
errTODO
=
errors
.
New
(
"TODO"
)
type
Configuration
*
IpfsNode
// define a different type
type
ConfigOption
func
(
ctx
context
.
Context
)
(
Configuration
,
error
)
type
ConfigOption
func
(
ctx
context
.
Context
)
(
*
IpfsNode
,
error
)
func
NewIPFSNode
(
ctx
context
.
Context
,
option
ConfigOption
)
(
*
IpfsNode
,
error
)
{
config
,
err
:=
option
(
ctx
)
...
...
@@ -100,73 +98,68 @@ func Online(cfg *config.Config) ConfigOption {
// DEPRECATED: use Online, Offline functions
func
Standard
(
cfg
*
config
.
Config
,
online
bool
)
ConfigOption
{
return
func
(
ctx
context
.
Context
)
(
Configuration
,
error
)
{
return
NewIpfsNode
(
ctx
,
cfg
,
online
)
}
}
return
func
(
ctx
context
.
Context
)
(
n
*
IpfsNode
,
err
error
)
{
success
:=
false
// flip to true after all sub-system inits succeed
defer
func
()
{
if
!
success
&&
n
!=
nil
{
n
.
Close
()
}
}()
// NewIpfsNode constructs a new IpfsNode based on the given config.
// DEPRECATED: use `NewIPFSNode`
func
NewIpfsNode
(
ctx
context
.
Context
,
cfg
*
config
.
Config
,
online
bool
)
(
n
*
IpfsNode
,
err
error
)
{
success
:=
false
// flip to true after all sub-system inits succeed
defer
func
()
{
if
!
success
&&
n
!=
nil
{
n
.
Close
()
if
cfg
==
nil
{
return
nil
,
debugerror
.
Errorf
(
"configuration required"
)
}
n
=
&
IpfsNode
{
onlineMode
:
online
,
Config
:
cfg
,
}
}()
if
cfg
==
nil
{
return
nil
,
debugerror
.
Errorf
(
"configuration required"
)
}
n
.
ContextGroup
=
ctxgroup
.
WithContextAndTeardown
(
ctx
,
n
.
teardown
)
ctx
=
n
.
ContextGroup
.
Context
()
n
=
&
IpfsNode
{
onlineMode
:
online
,
Config
:
cfg
,
}
n
.
ContextGroup
=
ctxgroup
.
WithContextAndTeardown
(
ctx
,
n
.
teardown
)
ctx
=
n
.
ContextGroup
.
Context
()
// setup Peerstore
n
.
Peerstore
=
peer
.
NewPeerstore
()
// setup Peerstore
n
.
Peerstore
=
peer
.
NewPeerstore
()
// setup datastore.
if
n
.
Datastore
,
err
=
makeDatastore
(
cfg
.
Datastore
);
err
!=
nil
{
return
nil
,
debugerror
.
Wrap
(
err
)
}
// setup
datastore.
if
n
.
Datastore
,
err
=
makeDatastore
(
cfg
.
Datastore
);
err
!=
nil
{
return
nil
,
debugerror
.
Wrap
(
err
)
}
// setup
local peer ID (private key is loaded in online setup)
if
err
:
=
n
.
loadID
(
);
err
!=
nil
{
return
nil
,
err
}
// setup local peer ID (private key is loaded in online setup
)
if
err
:=
n
.
loadID
();
err
!=
nil
{
return
nil
,
err
}
n
.
Blockstore
,
err
=
bstore
.
WriteCached
(
bstore
.
NewBlockstore
(
n
.
Datastore
),
kSizeBlockstoreWriteCache
)
if
err
!=
nil
{
return
nil
,
debugerror
.
Wrap
(
err
)
}
n
.
Blockstore
,
err
=
bstore
.
WriteCached
(
bstore
.
NewBlockstore
(
n
.
Datastore
),
kSizeBlockstoreWriteCache
)
if
err
!=
nil
{
return
nil
,
debugerror
.
Wrap
(
err
)
}
// setup online services
if
online
{
if
err
:=
n
.
StartOnlineServices
();
err
!=
nil
{
return
nil
,
err
// debugerror.Wraps.
}
}
else
{
n
.
Exchange
=
offline
.
Exchange
(
n
.
Blockstore
)
}
// setup online services
if
online
{
if
err
:=
n
.
StartOnlineServices
();
err
!=
nil
{
return
nil
,
err
// debugerror.Wraps.
n
.
Blocks
,
err
=
bserv
.
New
(
n
.
Blockstore
,
n
.
Exchange
)
if
err
!=
nil
{
return
nil
,
debugerror
.
Wrap
(
err
)
}
}
else
{
n
.
Exchange
=
offline
.
Exchange
(
n
.
Blockstore
)
}
n
.
Blocks
,
err
=
bserv
.
New
(
n
.
Blockstore
,
n
.
Exchange
)
if
err
!=
nil
{
return
nil
,
debugerror
.
Wrap
(
err
)
}
n
.
DAG
=
merkledag
.
NewDAGService
(
n
.
Blocks
)
n
.
Pinning
,
err
=
pin
.
LoadPinner
(
n
.
Datastore
,
n
.
DAG
)
if
err
!=
nil
{
n
.
Pinning
=
pin
.
NewPinner
(
n
.
Datastore
,
n
.
DAG
)
}
n
.
Resolver
=
&
path
.
Resolver
{
DAG
:
n
.
DAG
}
n
.
DAG
=
merkledag
.
NewDAGService
(
n
.
Blocks
)
n
.
Pinning
,
err
=
pin
.
LoadPinner
(
n
.
Datastore
,
n
.
DAG
)
if
err
!=
nil
{
n
.
Pinning
=
pin
.
NewPinner
(
n
.
Datastore
,
n
.
DAG
)
success
=
true
return
n
,
nil
}
n
.
Resolver
=
&
path
.
Resolver
{
DAG
:
n
.
DAG
}
success
=
true
return
n
,
nil
}
func
(
n
*
IpfsNode
)
StartOnlineServices
()
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