Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ac42bb79
提交
ac42bb79
authored
2月 18, 2016
作者:
Richard Littauer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Capitalized DHT
License: MIT Signed-off-by:
Richard Littauer
<
richard.littauer@gmail.com
>
上级
f8eefba0
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
14 行增加
和
14 行删除
+14
-14
README.md
README.md
+1
-1
dht.go
core/commands/dht.go
+2
-2
root.go
core/commands/root.go
+1
-1
dev.md
dev.md
+1
-1
dht_net.go
routing/dht/dht_net.go
+2
-2
dht_test.go
routing/dht/dht_test.go
+2
-2
handlers.go
routing/dht/handlers.go
+1
-1
records.go
routing/dht/records.go
+4
-4
没有找到文件。
README.md
浏览文件 @
ac42bb79
...
...
@@ -158,7 +158,7 @@ USAGE:
id Show info about ipfs peers
bootstrap Add or remove bootstrap peers
swarm Manage connections to the p2p network
dht Query the
dht
for values or peers
dht Query the
DHT
for values or peers
ping Measure the latency of a connection
diag Print diagnostics
...
...
core/commands/dht.go
浏览文件 @
ac42bb79
...
...
@@ -319,7 +319,7 @@ var getValueDhtCmd = &cmds.Command{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Run a 'GetValue' query through the DHT."
,
ShortDescription
:
`
GetValue will return the value stored in the
dht
at the given key.
GetValue will return the value stored in the
DHT
at the given key.
`
,
},
...
...
@@ -422,7 +422,7 @@ var putValueDhtCmd = &cmds.Command{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Run a 'PutValue' query through the DHT."
,
ShortDescription
:
`
PutValue will store the given key value pair in the
dht
.
PutValue will store the given key value pair in the
DHT
.
`
,
},
...
...
core/commands/root.go
浏览文件 @
ac42bb79
...
...
@@ -59,7 +59,7 @@ NETWORK COMMANDS
id Show info about ipfs peers
bootstrap Add or remove bootstrap peers
swarm Manage connections to the p2p network
dht Query the
dht
for values or peers
dht Query the
DHT
for values or peers
ping Measure the latency of a connection
diag Print diagnostics
...
...
dev.md
浏览文件 @
ac42bb79
...
...
@@ -16,7 +16,7 @@ There are multiple subpackages:
-
`path`
- path resolution over merkledag data structure
-
`peer`
- identity + addresses of local and remote peers
-
`routing`
- the routing system
-
`routing/dht`
- the
dht
default routing system implementation
-
`routing/dht`
- the
DHT
default routing system implementation
-
`swarm`
- connection multiplexing, many peers and many transports
-
`util`
- various utilities
...
...
routing/dht/dht_net.go
浏览文件 @
ac42bb79
...
...
@@ -70,7 +70,7 @@ func (dht *IpfsDHT) handleNewMessage(s inet.Stream) {
// measure the RTT for latency measurements.
func
(
dht
*
IpfsDHT
)
sendRequest
(
ctx
context
.
Context
,
p
peer
.
ID
,
pmes
*
pb
.
Message
)
(
*
pb
.
Message
,
error
)
{
log
.
Debugf
(
"%s
dht
starting stream"
,
dht
.
self
)
log
.
Debugf
(
"%s
DHT
starting stream"
,
dht
.
self
)
s
,
err
:=
dht
.
host
.
NewStream
(
ctx
,
ProtocolDHT
,
p
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -108,7 +108,7 @@ func (dht *IpfsDHT) sendRequest(ctx context.Context, p peer.ID, pmes *pb.Message
// sendMessage sends out a message
func
(
dht
*
IpfsDHT
)
sendMessage
(
ctx
context
.
Context
,
p
peer
.
ID
,
pmes
*
pb
.
Message
)
error
{
log
.
Debugf
(
"%s
dht
starting stream"
,
dht
.
self
)
log
.
Debugf
(
"%s
DHT
starting stream"
,
dht
.
self
)
s
,
err
:=
dht
.
host
.
NewStream
(
ctx
,
ProtocolDHT
,
p
)
if
err
!=
nil
{
return
err
...
...
routing/dht/dht_test.go
浏览文件 @
ac42bb79
...
...
@@ -93,7 +93,7 @@ func connect(t *testing.T, ctx context.Context, a, b *IpfsDHT) {
func
bootstrap
(
t
*
testing
.
T
,
ctx
context
.
Context
,
dhts
[]
*
IpfsDHT
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
log
.
Debugf
(
"
bootstrapping dht
s..."
)
log
.
Debugf
(
"
Bootstrapping DHT
s..."
)
// tried async. sequential fares much better. compare:
// 100 async https://gist.github.com/jbenet/56d12f0578d5f34810b2
...
...
@@ -391,7 +391,7 @@ func TestPeriodicBootstrap(t *testing.T) {
connect
(
t
,
ctx
,
dhts
[
i
],
dhts
[(
i
+
1
)
%
len
(
dhts
)])
}
t
.
Logf
(
"
dht
s are now connected to 1-2 others."
,
nDHTs
)
t
.
Logf
(
"
DHT
s are now connected to 1-2 others."
,
nDHTs
)
for
_
,
dht
:=
range
dhts
{
rtlen
:=
dht
.
routingTable
.
Size
()
if
rtlen
>
2
{
...
...
routing/dht/handlers.go
浏览文件 @
ac42bb79
...
...
@@ -106,7 +106,7 @@ func (dht *IpfsDHT) checkLocalDatastore(k key.Key) (*pb.Record, error) {
rec
:=
new
(
pb
.
Record
)
err
=
proto
.
Unmarshal
(
byts
,
rec
)
if
err
!=
nil
{
log
.
Debug
(
"Failed to unmarshal
dht record from datastore
"
)
log
.
Debug
(
"Failed to unmarshal
DHT record from datastore.
"
)
return
nil
,
err
}
...
...
routing/dht/records.go
浏览文件 @
ac42bb79
...
...
@@ -42,7 +42,7 @@ func (dht *IpfsDHT) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, err
}
// last ditch effort: let's try the dht.
log
.
Debugf
(
"pk for %s not in peerstore, and peer failed.
trying dht
."
,
p
)
log
.
Debugf
(
"pk for %s not in peerstore, and peer failed.
Trying DHT
."
,
p
)
pkkey
:=
routing
.
KeyForPublicKey
(
p
)
val
,
err
:=
dht
.
GetValue
(
ctxT
,
pkkey
)
...
...
@@ -77,14 +77,14 @@ func (dht *IpfsDHT) getPublicKeyFromNode(ctx context.Context, p peer.ID) (ci.Pub
// node doesn't have key :(
record
:=
pmes
.
GetRecord
()
if
record
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
n
ode not responding with its public key: %s"
,
p
)
return
nil
,
fmt
.
Errorf
(
"
N
ode not responding with its public key: %s"
,
p
)
}
// Success! We were given the value. we don't need to check
// validity because a) we can't. b) we know the hash of the
// key we're looking for.
val
:=
record
.
GetValue
()
log
.
Debug
(
"
dht
got a value from other peer."
)
log
.
Debug
(
"
DHT
got a value from other peer."
)
pk
,
err
=
ci
.
UnmarshalPublicKey
(
val
)
if
err
!=
nil
{
...
...
@@ -100,7 +100,7 @@ func (dht *IpfsDHT) getPublicKeyFromNode(ctx context.Context, p peer.ID) (ci.Pub
}
// ok! it's valid. we got it!
log
.
Debugf
(
"
dht
got public key from node itself."
)
log
.
Debugf
(
"
DHT
got public key from node itself."
)
return
pk
,
nil
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论