Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
adbc85bf
提交
adbc85bf
authored
4月 01, 2019
作者:
Łukasz Magiera
提交者:
Steven Allen
4月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove old constructor code
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
c5f887dc
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
2 行增加
和
152 行删除
+2
-152
builder.go
core/builder.go
+2
-152
core.go
core/core.go
+0
-0
没有找到文件。
core/builder.go
浏览文件 @
adbc85bf
...
...
@@ -7,37 +7,23 @@ import (
"errors"
"os"
"syscall"
"time"
"go.uber.org/fx"
"github.com/ipfs/go-ipfs/p2p"
"github.com/ipfs/go-ipfs/provider"
filestore
"github.com/ipfs/go-ipfs/filestore"
namesys
"github.com/ipfs/go-ipfs/namesys"
pin
"github.com/ipfs/go-ipfs/pin"
repo
"github.com/ipfs/go-ipfs/repo"
cidv0v1
"github.com/ipfs/go-ipfs/thirdparty/cidv0v1"
"github.com/ipfs/go-ipfs/thirdparty/verifbs"
bserv
"github.com/ipfs/go-blockservice"
ds
"github.com/ipfs/go-datastore"
retry
"github.com/ipfs/go-datastore/retrystore"
dsync
"github.com/ipfs/go-datastore/sync"
bstore
"github.com/ipfs/go-ipfs-blockstore"
cfg
"github.com/ipfs/go-ipfs-config"
offline
"github.com/ipfs/go-ipfs-exchange-offline"
offroute
"github.com/ipfs/go-ipfs-routing/offline"
dag
"github.com/ipfs/go-merkledag"
metrics
"github.com/ipfs/go-metrics-interface"
resolver
"github.com/ipfs/go-path/resolver"
uio
"github.com/ipfs/go-unixfs/io"
libp2p
"github.com/libp2p/go-libp2p"
ci
"github.com/libp2p/go-libp2p-crypto"
p2phost
"github.com/libp2p/go-libp2p-host"
peer
"github.com/libp2p/go-libp2p-peer"
pstore
"github.com/libp2p/go-libp2p-peerstore"
)
type
BuildCfg
struct
{
...
...
@@ -245,6 +231,8 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
)
go
func
()
{
// Note that some services use contexts to signal shutting down, which is
// very suboptimal. This needs to be here until that's addressed somehow
<-
ctx
.
Done
()
app
.
Stop
(
context
.
Background
())
}()
...
...
@@ -252,25 +240,6 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
n
.
IsOnline
=
cfg
.
Online
n
.
app
=
app
/* n := &IpfsNode{
IsOnline: cfg.Online,
Repo: cfg.Repo,
ctx: ctx,
Peerstore: pstoremem.NewPeerstore(),
}
n.RecordValidator = record.NamespacedValidator{
"pk": record.PublicKeyValidator{},
"ipns": ipns.Validator{KeyBook: n.Peerstore},
}
*/
// TODO: port to lifetimes
// n.proc = goprocessctx.WithContextAndTeardown(ctx, n.teardown)
/*if err := setupNode(ctx, n, cfg); err != nil {
n.Close()
return nil, err
}*/
if
app
.
Err
()
!=
nil
{
return
nil
,
app
.
Err
()
}
...
...
@@ -295,122 +264,3 @@ func isTooManyFDError(err error) bool {
return
false
}
func
setupNode
(
ctx
context
.
Context
,
n
*
IpfsNode
,
cfg
*
BuildCfg
)
error
{
// setup local identity
if
err
:=
n
.
loadID
();
err
!=
nil
{
return
err
}
// load the private key (if present)
if
err
:=
n
.
loadPrivateKey
();
err
!=
nil
{
return
err
}
rds
:=
&
retry
.
Datastore
{
Batching
:
n
.
Repo
.
Datastore
(),
Delay
:
time
.
Millisecond
*
200
,
Retries
:
6
,
TempErrFunc
:
isTooManyFDError
,
}
// hash security
bs
:=
bstore
.
NewBlockstore
(
rds
)
bs
=
&
verifbs
.
VerifBS
{
Blockstore
:
bs
}
opts
:=
bstore
.
DefaultCacheOpts
()
conf
,
err
:=
n
.
Repo
.
Config
()
if
err
!=
nil
{
return
err
}
// TEMP: setting global sharding switch here
uio
.
UseHAMTSharding
=
conf
.
Experimental
.
ShardingEnabled
opts
.
HasBloomFilterSize
=
conf
.
Datastore
.
BloomFilterSize
if
!
cfg
.
Permanent
{
opts
.
HasBloomFilterSize
=
0
}
if
!
cfg
.
NilRepo
{
bs
,
err
=
bstore
.
CachedBlockstore
(
ctx
,
bs
,
opts
)
if
err
!=
nil
{
return
err
}
}
bs
=
bstore
.
NewIdStore
(
bs
)
bs
=
cidv0v1
.
NewBlockstore
(
bs
)
n
.
BaseBlocks
=
bs
n
.
GCLocker
=
bstore
.
NewGCLocker
()
n
.
Blockstore
=
bstore
.
NewGCBlockstore
(
bs
,
n
.
GCLocker
)
if
conf
.
Experimental
.
FilestoreEnabled
||
conf
.
Experimental
.
UrlstoreEnabled
{
// hash security
n
.
Filestore
=
filestore
.
NewFilestore
(
bs
,
n
.
Repo
.
FileManager
())
n
.
Blockstore
=
bstore
.
NewGCBlockstore
(
n
.
Filestore
,
n
.
GCLocker
)
n
.
Blockstore
=
&
verifbs
.
VerifBSGC
{
GCBlockstore
:
n
.
Blockstore
}
}
rcfg
,
err
:=
n
.
Repo
.
Config
()
if
err
!=
nil
{
return
err
}
if
rcfg
.
Datastore
.
HashOnRead
{
bs
.
HashOnRead
(
true
)
}
hostOption
:=
cfg
.
Host
if
cfg
.
DisableEncryptedConnections
{
innerHostOption
:=
hostOption
hostOption
=
func
(
ctx
context
.
Context
,
id
peer
.
ID
,
ps
pstore
.
Peerstore
,
options
...
libp2p
.
Option
)
(
p2phost
.
Host
,
error
)
{
return
innerHostOption
(
ctx
,
id
,
ps
,
append
(
options
,
libp2p
.
NoSecurity
)
...
)
}
// TODO: shouldn't this be Errorf to guarantee visibility?
log
.
Warningf
(
`Your IPFS node has been configured to run WITHOUT ENCRYPTED CONNECTIONS.
You will not be able to connect to any nodes configured to use encrypted connections`
)
}
if
cfg
.
Online
{
do
:=
setupDiscoveryOption
(
rcfg
.
Discovery
)
if
err
:=
n
.
startOnlineServices
(
ctx
,
cfg
.
Routing
,
hostOption
,
do
,
cfg
.
getOpt
(
"pubsub"
),
cfg
.
getOpt
(
"ipnsps"
),
cfg
.
getOpt
(
"mplex"
));
err
!=
nil
{
return
err
}
}
else
{
n
.
Exchange
=
offline
.
Exchange
(
n
.
Blockstore
)
n
.
Routing
=
offroute
.
NewOfflineRouter
(
n
.
Repo
.
Datastore
(),
n
.
RecordValidator
)
n
.
Namesys
=
namesys
.
NewNameSystem
(
n
.
Routing
,
n
.
Repo
.
Datastore
(),
0
)
}
n
.
Blocks
=
bserv
.
New
(
n
.
Blockstore
,
n
.
Exchange
)
n
.
DAG
=
dag
.
NewDAGService
(
n
.
Blocks
)
internalDag
:=
dag
.
NewDAGService
(
bserv
.
New
(
n
.
Blockstore
,
offline
.
Exchange
(
n
.
Blockstore
)))
n
.
Pinning
,
err
=
pin
.
LoadPinner
(
n
.
Repo
.
Datastore
(),
n
.
DAG
,
internalDag
)
if
err
!=
nil
{
// TODO: we should move towards only running 'NewPinner' explicitly on
// node init instead of implicitly here as a result of the pinner keys
// not being found in the datastore.
// this is kinda sketchy and could cause data loss
n
.
Pinning
=
pin
.
NewPinner
(
n
.
Repo
.
Datastore
(),
n
.
DAG
,
internalDag
)
}
n
.
Resolver
=
resolver
.
NewBasicResolver
(
n
.
DAG
)
// Provider
queue
,
err
:=
provider
.
NewQueue
(
ctx
,
"provider-v1"
,
n
.
Repo
.
Datastore
())
if
err
!=
nil
{
return
err
}
n
.
Provider
=
provider
.
NewProvider
(
ctx
,
queue
,
n
.
Routing
)
if
cfg
.
Online
{
if
err
:=
n
.
startLateOnlineServices
(
ctx
);
err
!=
nil
{
return
err
}
}
return
n
.
loadFilesRoot
()
}
core/core.go
浏览文件 @
adbc85bf
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论