Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
6b169819
提交
6b169819
authored
6月 01, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make the default repo for corebuilder work
上级
0494a4db
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
3 行删除
+34
-3
builder.go
core/builder.go
+34
-3
没有找到文件。
core/builder.go
浏览文件 @
6b169819
package
core
import
(
"crypto/rand"
"encoding/base64"
"errors"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
dsync
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key
"github.com/ipfs/go-ipfs/blocks/key"
ci
"github.com/ipfs/go-ipfs/p2p/crypto"
repo
"github.com/ipfs/go-ipfs/repo"
cfg
"github.com/ipfs/go-ipfs/repo/config"
)
var
ErrAlreadyBuilt
=
errors
.
New
(
"this builder has already been used"
)
...
...
@@ -28,10 +33,32 @@ func NewNodeBuilder() *NodeBuilder {
}
}
func
defaultRepo
()
repo
.
Repo
{
func
defaultRepo
()
(
repo
.
Repo
,
error
)
{
c
:=
cfg
.
Config
{}
priv
,
pub
,
err
:=
ci
.
GenerateKeyPairWithReader
(
ci
.
RSA
,
1024
,
rand
.
Reader
)
if
err
!=
nil
{
return
nil
,
err
}
data
,
err
:=
pub
.
Hash
()
if
err
!=
nil
{
return
nil
,
err
}
privkeyb
,
err
:=
priv
.
Bytes
()
if
err
!=
nil
{
return
nil
,
err
}
c
.
Bootstrap
=
cfg
.
DefaultBootstrapAddresses
c
.
Addresses
.
Swarm
=
[]
string
{
"/ip4/0.0.0.0/tcp/4001"
}
c
.
Identity
.
PeerID
=
key
.
Key
(
data
)
.
B58String
()
c
.
Identity
.
PrivKey
=
base64
.
StdEncoding
.
EncodeToString
(
privkeyb
)
return
&
repo
.
Mock
{
D
:
dsync
.
MutexWrap
(
ds
.
NewMapDatastore
()),
}
C
:
c
,
},
nil
}
func
(
nb
*
NodeBuilder
)
Online
()
*
NodeBuilder
{
...
...
@@ -65,7 +92,11 @@ func (nb *NodeBuilder) Build(ctx context.Context) (*IpfsNode, error) {
}
nb
.
built
=
true
if
nb
.
repo
==
nil
{
nb
.
repo
=
defaultRepo
()
r
,
err
:=
defaultRepo
()
if
err
!=
nil
{
return
nil
,
err
}
nb
.
repo
=
r
}
conf
:=
standardWithRouting
(
nb
.
repo
,
nb
.
online
,
nb
.
routing
,
nb
.
peerhost
)
return
NewIPFSNode
(
ctx
,
conf
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论