Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
e989d6fe
提交
e989d6fe
authored
10月 16, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move IDFromPubKey to peer pkg
上级
18cfe02d
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
16 行增加
和
17 行删除
+16
-17
init.go
cmd/ipfs/init.go
+2
-2
handshake.go
crypto/spipe/handshake.go
+1
-11
daemon_test.go
daemon/daemon_test.go
+2
-2
peer.go
peer/peer.go
+10
-0
dht_test.go
routing/dht/dht_test.go
+1
-2
没有找到文件。
cmd/ipfs/init.go
浏览文件 @
e989d6fe
...
...
@@ -10,7 +10,7 @@ import (
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
config
"github.com/jbenet/go-ipfs/config"
ci
"github.com/jbenet/go-ipfs/crypto"
spipe
"github.com/jbenet/go-ipfs/crypto/spipe
"
peer
"github.com/jbenet/go-ipfs/peer
"
updates
"github.com/jbenet/go-ipfs/updates"
u
"github.com/jbenet/go-ipfs/util"
)
...
...
@@ -121,7 +121,7 @@ func initCmd(c *commander.Command, inp []string) error {
}
cfg
.
Identity
.
PrivKey
=
base64
.
StdEncoding
.
EncodeToString
(
skbytes
)
id
,
err
:=
spipe
.
IDFromPubKey
(
pk
)
id
,
err
:=
peer
.
IDFromPubKey
(
pk
)
if
err
!=
nil
{
return
err
}
...
...
crypto/spipe/handshake.go
浏览文件 @
e989d6fe
...
...
@@ -288,16 +288,6 @@ func (s *SecurePipe) handleSecureOut(hashType string, mIV, mCKey, mMKey []byte)
}
}
// IDFromPubKey retrieves a Public Key from the peer given by pk
func
IDFromPubKey
(
pk
ci
.
PubKey
)
(
peer
.
ID
,
error
)
{
b
,
err
:=
pk
.
Bytes
()
if
err
!=
nil
{
return
nil
,
err
}
hash
:=
u
.
Hash
(
b
)
return
peer
.
ID
(
hash
),
nil
}
// Determines which algorithm to use. Note: f(a, b) = f(b, a)
func
selectBest
(
myPrefs
,
theirPrefs
string
)
(
string
,
error
)
{
// Person with greatest hash gets first choice.
...
...
@@ -334,7 +324,7 @@ func selectBest(myPrefs, theirPrefs string) (string, error) {
// else, construct it.
func
getOrConstructPeer
(
peers
peer
.
Peerstore
,
rpk
ci
.
PubKey
)
(
*
peer
.
Peer
,
error
)
{
rid
,
err
:=
IDFromPubKey
(
rpk
)
rid
,
err
:=
peer
.
IDFromPubKey
(
rpk
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
daemon/daemon_test.go
浏览文件 @
e989d6fe
...
...
@@ -9,7 +9,7 @@ import (
config
"github.com/jbenet/go-ipfs/config"
core
"github.com/jbenet/go-ipfs/core"
ci
"github.com/jbenet/go-ipfs/crypto"
spipe
"github.com/jbenet/go-ipfs/crypto/spipe
"
peer
"github.com/jbenet/go-ipfs/peer
"
)
func
TestInitializeDaemonListener
(
t
*
testing
.
T
)
{
...
...
@@ -23,7 +23,7 @@ func TestInitializeDaemonListener(t *testing.T) {
t
.
Fatal
(
err
)
}
ident
,
_
:=
spipe
.
IDFromPubKey
(
pub
)
ident
,
_
:=
peer
.
IDFromPubKey
(
pub
)
privKey
:=
base64
.
StdEncoding
.
EncodeToString
(
prbytes
)
pID
:=
ident
.
Pretty
()
...
...
peer/peer.go
浏览文件 @
e989d6fe
...
...
@@ -36,6 +36,16 @@ func DecodePrettyID(s string) ID {
return
b58
.
Decode
(
s
)
}
// IDFromPubKey retrieves a Public Key from the peer given by pk
func
IDFromPubKey
(
pk
ic
.
PubKey
)
(
ID
,
error
)
{
b
,
err
:=
pk
.
Bytes
()
if
err
!=
nil
{
return
nil
,
err
}
hash
:=
u
.
Hash
(
b
)
return
ID
(
hash
),
nil
}
// Map maps Key (string) : *Peer (slices are not comparable).
type
Map
map
[
u
.
Key
]
*
Peer
...
...
routing/dht/dht_test.go
浏览文件 @
e989d6fe
...
...
@@ -10,7 +10,6 @@ import (
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
ci
"github.com/jbenet/go-ipfs/crypto"
spipe
"github.com/jbenet/go-ipfs/crypto/spipe"
inet
"github.com/jbenet/go-ipfs/net"
mux
"github.com/jbenet/go-ipfs/net/mux"
netservice
"github.com/jbenet/go-ipfs/net/service"
...
...
@@ -74,7 +73,7 @@ func makePeer(addr ma.Multiaddr) *peer.Peer {
}
p
.
PrivKey
=
sk
p
.
PubKey
=
pk
id
,
err
:=
spipe
.
IDFromPubKey
(
pk
)
id
,
err
:=
peer
.
IDFromPubKey
(
pk
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论