Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ccc576b6
提交
ccc576b6
authored
3月 28, 2019
作者:
Łukasz Magiera
提交者:
Steven Allen
4月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More constructor fixes
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
65d8fad0
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
47 行增加
和
31 行删除
+47
-31
builder.go
core/builder.go
+19
-12
core.go
core/core.go
+18
-14
ncore.go
core/ncore.go
+10
-5
没有找到文件。
core/builder.go
浏览文件 @
ccc576b6
...
...
@@ -162,6 +162,7 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
storage
:=
fx
.
Options
(
fx
.
Provide
(
repoConfig
),
fx
.
Provide
(
datastoreCtor
),
fx
.
Provide
(
baseBlockstoreCtor
),
fx
.
Provide
(
gcBlockstoreCtor
),
)
...
...
@@ -169,23 +170,39 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
ident
:=
fx
.
Options
(
fx
.
Provide
(
identity
),
fx
.
Provide
(
privateKey
),
fx
.
Provide
(
peerstore
),
)
ipns
:=
fx
.
Options
(
fx
.
Provide
(
recordValidator
),
)
providers
:=
fx
.
Options
(
fx
.
Provide
(
providerQueue
),
fx
.
Provide
(
providerCtor
),
fx
.
Provide
(
reproviderCtor
),
fx
.
Invoke
(
reprovider
),
fx
.
Invoke
(
provider
.
Provider
.
Run
),
)
online
:=
fx
.
Options
(
fx
.
Provide
(
onlineExchangeCtor
),
fx
.
Provide
(
onlineNamesysCtor
),
fx
.
Invoke
(
ipnsRepublisher
),
fx
.
Invoke
(
provider
.
Provider
.
Run
),
fx
.
Provide
(
p2p
.
NewP2P
),
ipfsp2p
,
providers
,
)
if
!
cfg
.
Online
{
online
=
fx
.
Options
(
fx
.
Provide
(
offline
.
Exchange
),
fx
.
Provide
(
offlineNamesysCtor
),
fx
.
Provide
(
offroute
.
NewOfflineRouter
),
fx
.
Provide
(
provider
.
NewOfflineProvider
),
)
}
...
...
@@ -197,13 +214,6 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
fx
.
Provide
(
files
),
)
providers
:=
fx
.
Options
(
fx
.
Provide
(
providerQueue
),
fx
.
Provide
(
providerCtor
),
fx
.
Provide
(
reproviderCtor
),
fx
.
Invoke
(
reprovider
),
)
n
:=
&
IpfsNode
{
ctx
:
ctx
,
}
...
...
@@ -212,21 +222,18 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
params
,
storage
,
ident
,
ipfsp2p
,
ipns
,
online
,
fx
.
Invoke
(
setupSharding
),
core
,
providers
,
fx
.
Provide
(
p2p
.
NewP2P
),
fx
.
Extract
(
n
),
)
n
.
IsOnline
=
cfg
.
Online
n
.
app
=
app
/* n := &IpfsNode{
IsOnline: cfg.Online,
...
...
core/core.go
浏览文件 @
ccc576b6
...
...
@@ -20,6 +20,8 @@ import (
"strings"
"time"
"go.uber.org/fx"
version
"github.com/ipfs/go-ipfs"
rp
"github.com/ipfs/go-ipfs/exchange/reprovide"
filestore
"github.com/ipfs/go-ipfs/filestore"
...
...
@@ -101,10 +103,10 @@ type IpfsNode struct {
Pinning
pin
.
Pinner
// the pinning manager
Mounts
Mounts
`optional:"true"`
// current mount state, if any.
PrivateKey
ic
.
PrivKey
// the local node's private Key
PNetFingerprint
PNetFingerprint
// fingerprint of private network
PNetFingerprint
PNetFingerprint
`optional:"true"`
// fingerprint of private network
// Services
Peerstore
pstore
.
Peerstore
// storage for other Peer instances
Peerstore
pstore
.
Peerstore
`optional:"true"`
// storage for other Peer instances
Blockstore
bstore
.
GCBlockstore
// the block store (lower level)
Filestore
*
filestore
.
Filestore
// the filestore blockstore
BaseBlocks
bstore
.
Blockstore
// the raw blockstore, no filestore wrapping
...
...
@@ -112,30 +114,32 @@ type IpfsNode struct {
Blocks
bserv
.
BlockService
// the block service, get/add blocks.
DAG
ipld
.
DAGService
// the merkle dag service, get/add objects.
Resolver
*
resolver
.
Resolver
// the path resolution system
Reporter
metrics
.
Reporter
Reporter
metrics
.
Reporter
`optional:"true"`
Discovery
discovery
.
Service
`optional:"true"`
FilesRoot
*
mfs
.
Root
RecordValidator
record
.
Validator
// Online
PeerHost
p2phost
.
Host
// the network host (server+client)
PeerHost
p2phost
.
Host
`optional:"true"`
// the network host (server+client)
Bootstrapper
io
.
Closer
`optional:"true"`
// the periodic bootstrapper
Routing
routing
.
IpfsRouting
// the routing system. recommend ipfs-dht
Routing
routing
.
IpfsRouting
`optional:"true"`
// the routing system. recommend ipfs-dht
Exchange
exchange
.
Interface
// the block exchange + strategy (bitswap)
Namesys
namesys
.
NameSystem
// the name system, resolves paths to hashes
Provider
provider
.
Provider
// the value provider system
Reprovider
*
rp
.
Reprovider
// the value reprovider system
Provider
provider
.
Provider
// the value provider system
Reprovider
*
rp
.
Reprovider
`optional:"true"`
// the value reprovider system
IpnsRepub
*
ipnsrp
.
Republisher
`optional:"true"`
AutoNAT
*
autonat
.
AutoNATService
`optional:"true"`
PubSub
*
pubsub
.
PubSub
PSRouter
*
psrouter
.
PubsubValueStore
DHT
*
dht
.
IpfsDHT
P2P
*
p2p
.
P2P
PubSub
*
pubsub
.
PubSub
`optional:"true"`
PSRouter
*
psrouter
.
PubsubValueStore
`optional:"true"`
DHT
*
dht
.
IpfsDHT
`optional:"true"`
P2P
*
p2p
.
P2P
`optional:"true"`
proc
goprocess
.
Process
proc
goprocess
.
Process
//TODO: remove
ctx
context
.
Context
app
*
fx
.
App
// Flags
IsOnline
bool
`optional:"true"`
// Online is set when networking is enabled.
IsDaemon
bool
`optional:"true"`
// Daemon is set when running on a long-running daemon.
...
...
@@ -648,9 +652,9 @@ func (n *IpfsNode) Process() goprocess.Process {
return
n
.
proc
}
// Close calls Close() on the
Process
object
// Close calls Close() on the
App
object
func
(
n
*
IpfsNode
)
Close
()
error
{
return
n
.
proc
.
Close
(
)
return
n
.
app
.
Stop
(
n
.
ctx
)
}
// Context returns the IpfsNode context
...
...
core/ncore.go
浏览文件 @
ccc576b6
...
...
@@ -111,6 +111,10 @@ func privateKey(cfg *iconfig.Config, id peer.ID) (ic.PrivKey, error) {
return
sk
,
nil
}
func
datastoreCtor
(
repo
repo
.
Repo
)
ds
.
Datastore
{
return
repo
.
Datastore
()
}
func
baseBlockstoreCtor
(
repo
repo
.
Repo
,
cfg
*
iconfig
.
Config
,
bcfg
*
BuildCfg
,
lc
fx
.
Lifecycle
)
(
bs
bstore
.
Blockstore
,
err
error
)
{
rds
:=
&
retry
.
Datastore
{
Batching
:
repo
.
Datastore
(),
...
...
@@ -180,8 +184,6 @@ func recordValidator(ps pstore.Peerstore) record.Validator {
// libp2p
var
ipfsp2p
=
fx
.
Options
(
fx
.
Provide
(
peerstore
),
fx
.
Provide
(
p2pAddrFilters
),
fx
.
Provide
(
p2pBandwidthCounter
),
fx
.
Provide
(
p2pPNet
),
...
...
@@ -411,6 +413,9 @@ func p2pHost(lc fx.Lifecycle, params p2pHostIn) (out p2pHostOut, err error) {
}))
out
.
Host
,
err
=
params
.
HostOption
(
ctx
,
params
.
ID
,
params
.
Peerstore
,
opts
...
)
if
err
!=
nil
{
return
p2pHostOut
{},
err
}
// this code is necessary just for tests: mock network constructions
// ignore the libp2p constructor options that actually construct the routing!
...
...
@@ -758,14 +763,14 @@ func lifecycleCtx(lc fx.Lifecycle) context.Context {
}
func
lcGoProc
(
lc
fx
.
Lifecycle
,
processFunc
goprocess
.
ProcessFunc
)
{
proc
:=
goprocess
.
Background
(
)
proc
:=
make
(
chan
goprocess
.
Process
,
1
)
lc
.
Append
(
fx
.
Hook
{
OnStart
:
func
(
ctx
context
.
Context
)
error
{
proc
.
Go
(
processFunc
)
proc
<-
goprocess
.
Go
(
processFunc
)
return
nil
},
OnStop
:
func
(
ctx
context
.
Context
)
error
{
return
proc
.
Close
()
// todo: respect ctx
return
(
<-
proc
)
.
Close
()
// todo: respect ctx
},
})
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论