Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
547f9e1c
提交
547f9e1c
authored
9月 17, 2014
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(core) patiently convince the core to compile
=)
上级
56e6c453
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
14 行删除
+25
-14
core.go
core/core.go
+25
-14
没有找到文件。
core/core.go
浏览文件 @
547f9e1c
...
@@ -47,7 +47,7 @@ type IpfsNode struct {
...
@@ -47,7 +47,7 @@ type IpfsNode struct {
Routing
routing
.
IpfsRouting
Routing
routing
.
IpfsRouting
// the block exchange + strategy (bitswap)
// the block exchange + strategy (bitswap)
BitSwap
bitswap
.
BitSwap
BitSwap
bitswap
.
Exchange
// the block service, get/add blocks.
// the block service, get/add blocks.
Blocks
*
bserv
.
BlockService
Blocks
*
bserv
.
BlockService
...
@@ -80,37 +80,48 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
...
@@ -80,37 +80,48 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
peerstore
:=
peer
.
NewPeerstore
()
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
(
var
(
net
*
inet
.
Network
net
inet
.
Network
// TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific
// TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific
route
*
dht
.
IpfsDHT
route
*
dht
.
IpfsDHT
exchangeSession
bitswap
.
Exchange
)
)
if
online
{
if
online
{
// add protocol services here.
// add protocol services here.
ctx
:=
context
.
TODO
()
// derive this from a higher context.
ctx
:=
context
.
TODO
()
// derive this from a higher context.
dhts
:=
netservice
.
Service
(
nil
)
// nil handler for now, need to patch it
dhtService
:=
netservice
.
NewService
(
nil
)
// nil handler for now, need to patch it
if
err
:=
dhts
.
Start
(
ctx
);
err
!=
nil
{
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
return
nil
,
err
}
}
net
,
err
:
=
inet
.
NewIpfsNetwork
(
context
.
TODO
(),
local
,
&
mux
.
ProtocolMap
{
net
,
err
=
inet
.
NewIpfsNetwork
(
context
.
TODO
(),
local
,
&
mux
.
ProtocolMap
{
netservice
.
ProtocolID_Routing
:
dhtService
,
mux
.
ProtocolID_Routing
:
dhtService
,
// netservice.ProtocolID_Bitswap: bitswap
Service,
mux
.
ProtocolID_Exchange
:
exchange
Service
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
route
=
dht
.
NewDHT
(
local
,
peerstore
,
net
,
dhts
,
d
)
route
=
dht
.
NewDHT
(
local
,
peerstore
,
net
,
dhtService
,
d
)
dhts
.
Handler
=
route
// wire the handler to the service.
// 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
// TODO(brian): pass a context to DHT for its async operations
route
.
Start
()
route
.
Start
()
// TODO(brian): pass a context to bs for its async operations
// TODO(brian): pass a context to bs for its async operations
bitswapSession
:=
bitswap
.
NewSession
(
context
.
TODO
()
,
local
,
d
,
route
)
exchangeSession
=
bitswap
.
NewSession
(
ctx
,
exchangeService
,
local
,
d
,
route
)
// TODO(brian): pass a context to initConnections
// TODO(brian): pass a context to initConnections
go
initConnections
(
cfg
,
route
)
go
initConnections
(
cfg
,
route
)
...
@@ -118,7 +129,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
...
@@ -118,7 +129,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
// TODO(brian): when offline instantiate the BlockService with a bitswap
// TODO(brian): when offline instantiate the BlockService with a bitswap
// session that simply doesn't return blocks
// session that simply doesn't return blocks
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
bitswap
Session
)
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
exchange
Session
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -127,12 +138,12 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
...
@@ -127,12 +138,12 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
return
&
IpfsNode
{
return
&
IpfsNode
{
Config
:
cfg
,
Config
:
cfg
,
Peerstore
:
peerstore
,
Peerstore
:
&
peerstore
,
Datastore
:
d
,
Datastore
:
d
,
Blocks
:
bs
,
Blocks
:
bs
,
DAG
:
dag
,
DAG
:
dag
,
Resolver
:
&
path
.
Resolver
{
DAG
:
dag
},
Resolver
:
&
path
.
Resolver
{
DAG
:
dag
},
BitSwap
:
bitswap
Session
,
BitSwap
:
exchange
Session
,
Identity
:
local
,
Identity
:
local
,
Routing
:
route
,
Routing
:
route
,
},
nil
},
nil
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论