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
547f9e1c
Commit
547f9e1c
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(core) patiently convince the core to compile
=)
parent
56e6c453
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
core/core.go
core/core.go
+25
-14
No files found.
core/core.go
View file @
547f9e1c
...
...
@@ -47,7 +47,7 @@ type IpfsNode struct {
Routing
routing
.
IpfsRouting
// the block exchange + strategy (bitswap)
BitSwap
bitswap
.
BitSwap
BitSwap
bitswap
.
Exchange
// the block service, get/add blocks.
Blocks
*
bserv
.
BlockService
...
...
@@ -80,37 +80,48 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
peerstore
:=
peer
.
NewPeerstore
()
// FIXME(brian): This is a bit dangerous. If any of the vars declared in
// this block are assigned inside of the "if online" block using the ":="
// declaration syntax, the compiler permits re-declaration. This is rather
// undesirable
var
(
net
*
inet
.
Network
net
inet
.
Network
// TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific
route
*
dht
.
IpfsDHT
route
*
dht
.
IpfsDHT
exchangeSession
bitswap
.
Exchange
)
if
online
{
// add protocol services here.
ctx
:=
context
.
TODO
()
// derive this from a higher context.
dhts
:=
netservice
.
Service
(
nil
)
// nil handler for now, need to patch it
if
err
:=
dhts
.
Start
(
ctx
);
err
!=
nil
{
dhtService
:=
netservice
.
NewService
(
nil
)
// nil handler for now, need to patch it
exchangeService
:=
netservice
.
NewService
(
nil
)
// nil handler for now, need to patch it
if
err
:=
dhtService
.
Start
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
if
err
:=
exchangeService
.
Start
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
net
,
err
:
=
inet
.
NewIpfsNetwork
(
context
.
TODO
(),
local
,
&
mux
.
ProtocolMap
{
netservice
.
ProtocolID_Routing
:
dhtService
,
// netservice.ProtocolID_Bitswap: bitswap
Service,
net
,
err
=
inet
.
NewIpfsNetwork
(
context
.
TODO
(),
local
,
&
mux
.
ProtocolMap
{
mux
.
ProtocolID_Routing
:
dhtService
,
mux
.
ProtocolID_Exchange
:
exchange
Service
,
})
if
err
!=
nil
{
return
nil
,
err
}
route
=
dht
.
NewDHT
(
local
,
peerstore
,
net
,
dhts
,
d
)
dhts
.
Handler
=
route
// wire the handler to the service.
route
=
dht
.
NewDHT
(
local
,
peerstore
,
net
,
dhtService
,
d
)
// TODO(brian): perform this inside NewDHT factory method
dhtService
.
Handler
=
route
// wire the handler to the service.
// TODO(brian): pass a context to DHT for its async operations
route
.
Start
()
// TODO(brian): pass a context to bs for its async operations
bitswap
Session
:
=
bitswap
.
NewSession
(
c
ontext
.
TODO
()
,
local
,
d
,
route
)
exchange
Session
=
bitswap
.
NewSession
(
c
tx
,
exchangeService
,
local
,
d
,
route
)
// TODO(brian): pass a context to initConnections
go
initConnections
(
cfg
,
route
)
...
...
@@ -118,7 +129,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
// TODO(brian): when offline instantiate the BlockService with a bitswap
// session that simply doesn't return blocks
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
bitswap
Session
)
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
exchange
Session
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -127,12 +138,12 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
return
&
IpfsNode
{
Config
:
cfg
,
Peerstore
:
peerstore
,
Peerstore
:
&
peerstore
,
Datastore
:
d
,
Blocks
:
bs
,
DAG
:
dag
,
Resolver
:
&
path
.
Resolver
{
DAG
:
dag
},
BitSwap
:
bitswap
Session
,
BitSwap
:
exchange
Session
,
Identity
:
local
,
Routing
:
route
,
},
nil
...
...
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