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
1bd69b19
Commit
1bd69b19
authored
Jan 10, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: make sure to call swarm.FilterAddrs
also move network setup into its own self-contained func
parent
66f1a5a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
19 deletions
+30
-19
core/core.go
core/core.go
+30
-19
No files found.
core/core.go
View file @
1bd69b19
...
...
@@ -150,26 +150,9 @@ func (n *IpfsNode) StartOnlineServices() error {
return
err
}
// setup the network
listenAddrs
,
err
:=
listenAddresses
(
n
.
Config
)
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
}
network
,
err
:=
swarm
.
NewNetwork
(
ctx
,
listenAddrs
,
n
.
Identity
,
n
.
Peerstore
)
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
}
n
.
AddChildGroup
(
network
.
CtxGroup
())
n
.
PeerHost
=
p2pbhost
.
New
(
network
)
// explicitly set these as our listen addrs.
// (why not do it inside inet.NewNetwork? because this way we can
// listen on addresses without necessarily advertising those publicly.)
addrs
,
err
:=
n
.
PeerHost
.
Network
()
.
InterfaceListenAddresses
()
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
if
err
:=
n
.
startNetwork
();
err
!=
nil
{
return
err
}
n
.
Peerstore
.
AddAddresses
(
n
.
Identity
,
addrs
)
// setup diagnostics service
n
.
Diagnostics
=
diag
.
NewDiagnostics
(
n
.
Identity
,
n
.
PeerHost
)
...
...
@@ -199,6 +182,34 @@ func (n *IpfsNode) StartOnlineServices() error {
return
nil
}
func
(
n
*
IpfsNode
)
startNetwork
()
error
{
ctx
:=
n
.
Context
()
// setup the network
listenAddrs
,
err
:=
listenAddresses
(
n
.
Config
)
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
}
// make sure we dont error out if our config includes some addresses we cant use.
listenAddrs
=
swarm
.
FilterAddrs
(
listenAddrs
)
network
,
err
:=
swarm
.
NewNetwork
(
ctx
,
listenAddrs
,
n
.
Identity
,
n
.
Peerstore
)
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
}
n
.
AddChildGroup
(
network
.
CtxGroup
())
n
.
PeerHost
=
p2pbhost
.
New
(
network
)
// explicitly set these as our listen addrs.
// (why not do it inside inet.NewNetwork? because this way we can
// listen on addresses without necessarily advertising those publicly.)
addrs
,
err
:=
n
.
PeerHost
.
Network
()
.
InterfaceListenAddresses
()
if
err
!=
nil
{
return
debugerror
.
Wrap
(
err
)
}
n
.
Peerstore
.
AddAddresses
(
n
.
Identity
,
addrs
)
return
nil
}
func
(
n
*
IpfsNode
)
teardown
()
error
{
if
err
:=
n
.
Datastore
.
Close
();
err
!=
nil
{
return
err
...
...
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