Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
375a38c5
提交
375a38c5
authored
9月 25, 2014
作者:
Jeromy
提交者:
Juan Batiz-Benet
10月 01, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add basic publish command, needs polish
上级
16aa6362
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
30 行增加
和
6 行删除
+30
-6
ipfs.go
cmd/ipfs/ipfs.go
+2
-0
run.go
cmd/ipfs/run.go
+1
-1
daemon.go
daemon/daemon.go
+2
-0
publisher.go
namesys/publisher.go
+14
-2
dht.go
routing/dht/dht.go
+3
-0
query.go
routing/dht/query.go
+6
-1
routing.go
routing/dht/routing.go
+2
-2
没有找到文件。
cmd/ipfs/ipfs.go
浏览文件 @
375a38c5
...
...
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"runtime/pprof"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
...
...
@@ -51,6 +52,7 @@ Use "ipfs help <command>" for more information about a command.
cmdIpfsInit
,
cmdIpfsServe
,
cmdIpfsRun
,
cmdIpfsPub
,
},
Flag
:
*
flag
.
NewFlagSet
(
"ipfs"
,
flag
.
ExitOnError
),
}
...
...
cmd/ipfs/run.go
浏览文件 @
375a38c5
...
...
@@ -41,7 +41,7 @@ func runCmd(c *commander.Command, inp []string) error {
return
err
}
dl
,
err
:=
daemon
.
NewDaemonListener
(
n
,
maddr
)
dl
,
err
:=
daemon
.
NewDaemonListener
(
n
,
maddr
,
conf
)
if
err
!=
nil
{
return
err
}
...
...
daemon/daemon.go
浏览文件 @
375a38c5
...
...
@@ -131,6 +131,8 @@ func (dl *DaemonListener) handleConnection(conn net.Conn) {
err
=
commands
.
Ls
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"pin"
:
err
=
commands
.
Pin
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"publish"
:
err
=
commands
.
Publish
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
default
:
err
=
fmt
.
Errorf
(
"Invalid Command: '%s'"
,
command
.
Command
)
}
...
...
namesys/publisher.go
浏览文件 @
375a38c5
package
namesys
import
(
"time"
"code.google.com/p/go.net/context"
"code.google.com/p/goprotobuf/proto"
...
...
@@ -15,8 +17,16 @@ type IpnsPublisher struct {
routing
routing
.
IpfsRouting
}
func
NewPublisher
(
dag
*
mdag
.
DAGService
,
route
routing
.
IpfsRouting
)
*
IpnsPublisher
{
return
&
IpnsPublisher
{
dag
:
dag
,
routing
:
route
,
}
}
// Publish accepts a keypair and a value,
func
(
p
*
IpnsPublisher
)
Publish
(
k
ci
.
PrivKey
,
value
u
.
Key
)
error
{
log
.
Debug
(
"namesys: Publish %s"
,
value
.
Pretty
())
ctx
:=
context
.
TODO
()
data
,
err
:=
CreateEntryData
(
k
,
value
)
if
err
!=
nil
{
...
...
@@ -40,13 +50,15 @@ func (p *IpnsPublisher) Publish(k ci.PrivKey, value u.Key) error {
}
// Store associated public key
err
=
p
.
routing
.
PutValue
(
ctx
,
u
.
Key
(
nameb
),
pkbytes
)
timectx
,
_
:=
context
.
WithDeadline
(
ctx
,
time
.
Now
()
.
Add
(
time
.
Second
*
4
))
err
=
p
.
routing
.
PutValue
(
timectx
,
u
.
Key
(
nameb
),
pkbytes
)
if
err
!=
nil
{
return
err
}
// Store ipns entry at h("/ipns/"+b58(h(pubkey)))
err
=
p
.
routing
.
PutValue
(
ctx
,
u
.
Key
(
ipnskey
),
data
)
timectx
,
_
=
context
.
WithDeadline
(
ctx
,
time
.
Now
()
.
Add
(
time
.
Second
*
4
))
err
=
p
.
routing
.
PutValue
(
timectx
,
u
.
Key
(
ipnskey
),
data
)
if
err
!=
nil
{
return
err
}
...
...
routing/dht/dht.go
浏览文件 @
375a38c5
...
...
@@ -13,6 +13,7 @@ import (
peer
"github.com/jbenet/go-ipfs/peer"
kb
"github.com/jbenet/go-ipfs/routing/kbucket"
u
"github.com/jbenet/go-ipfs/util"
"github.com/op/go-logging"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
...
...
@@ -21,6 +22,8 @@ import (
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
var
log
=
logging
.
MustGetLogger
(
"dht"
)
// TODO. SEE https://github.com/jbenet/node-ipfs/blob/master/submodules/ipfs-dht/index.js
// IpfsDHT is an implementation of Kademlia with Coral and S/Kademlia modifications.
...
...
routing/dht/query.go
浏览文件 @
375a38c5
...
...
@@ -101,6 +101,11 @@ func newQueryRunner(ctx context.Context, q *dhtQuery) *dhtQueryRunner {
}
func
(
r
*
dhtQueryRunner
)
Run
(
peers
[]
*
peer
.
Peer
)
(
*
dhtQueryResult
,
error
)
{
log
.
Debug
(
"Run query with %d peers."
,
len
(
peers
))
if
len
(
peers
)
==
0
{
log
.
Warning
(
"Running query with no peers!"
)
return
nil
,
nil
}
// setup concurrency rate limiting
for
i
:=
0
;
i
<
r
.
query
.
concurrency
;
i
++
{
r
.
rateLimit
<-
struct
{}{}
...
...
@@ -164,7 +169,7 @@ func (r *dhtQueryRunner) addPeerToQuery(next *peer.Peer, benchmark *peer.Peer) {
r
.
peersSeen
[
next
.
Key
()]
=
next
r
.
Unlock
()
u
.
DOut
(
"adding peer to query: %v
\n
"
,
next
.
ID
.
Pretty
())
log
.
Debug
(
"adding peer to query: %v
\n
"
,
next
.
ID
.
Pretty
())
// do this after unlocking to prevent possible deadlocks.
r
.
peersRemaining
.
Increment
(
1
)
...
...
routing/dht/routing.go
浏览文件 @
375a38c5
...
...
@@ -18,6 +18,7 @@ import (
// PutValue adds value corresponding to given Key.
// This is the top level "Store" operation of the DHT
func
(
dht
*
IpfsDHT
)
PutValue
(
ctx
context
.
Context
,
key
u
.
Key
,
value
[]
byte
)
error
{
log
.
Debug
(
"[%s] PutValue %v %v"
,
dht
.
self
.
ID
.
Pretty
(),
key
,
value
)
err
:=
dht
.
putLocal
(
key
,
value
)
if
err
!=
nil
{
return
err
...
...
@@ -30,7 +31,7 @@ func (dht *IpfsDHT) PutValue(ctx context.Context, key u.Key, value []byte) error
}
query
:=
newQuery
(
key
,
func
(
ctx
context
.
Context
,
p
*
peer
.
Peer
)
(
*
dhtQueryResult
,
error
)
{
u
.
DOut
(
"[%s] PutValue qry part %v
\n
"
,
dht
.
self
.
ID
.
Pretty
(),
p
.
ID
.
Pretty
())
log
.
Debug
(
"[%s] PutValue qry part %v
"
,
dht
.
self
.
ID
.
Pretty
(),
p
.
ID
.
Pretty
())
err
:=
dht
.
putValueToNetwork
(
ctx
,
p
,
string
(
key
),
value
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -39,7 +40,6 @@ func (dht *IpfsDHT) PutValue(ctx context.Context, key u.Key, value []byte) error
})
_
,
err
=
query
.
Run
(
ctx
,
peers
)
u
.
DOut
(
"[%s] PutValue %v %v
\n
"
,
dht
.
self
.
ID
.
Pretty
(),
key
,
value
)
return
err
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论