Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
97e1c953
提交
97e1c953
authored
4月 12, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1063 from AtnNn/publish-path
Publish by path
上级
264ada51
233c39ff
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
48 行增加
和
13 行删除
+48
-13
publish.go
core/commands/publish.go
+20
-8
test-lib-hashes.sh
test/sharness/lib/test-lib-hashes.sh
+1
-0
t0100-name.sh
test/sharness/t0100-name.sh
+27
-5
没有找到文件。
core/commands/publish.go
浏览文件 @
97e1c953
...
...
@@ -12,6 +12,7 @@ import (
core
"github.com/ipfs/go-ipfs/core"
nsys
"github.com/ipfs/go-ipfs/namesys"
crypto
"github.com/ipfs/go-ipfs/p2p/crypto"
path
"github.com/ipfs/go-ipfs/path"
u
"github.com/ipfs/go-ipfs/util"
)
...
...
@@ -32,12 +33,12 @@ default value of <name> is your own identity public key.
Examples:
Publish a
<ref
> to your identity name:
Publish a
n <ipfs-path
> to your identity name:
> ipfs name publish QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
> ipfs name publish
/ipfs/
QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
published name QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n to QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
Publish a
<ref> to another public key
:
Publish a
n <ipfs-path> to another public key (not implemented)
:
> ipfs name publish QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
published name QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n to QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
...
...
@@ -71,21 +72,32 @@ Publish a <ref> to another public key:
return
}
// name := ""
ref
:=
""
var
pstr
string
switch
len
(
args
)
{
case
2
:
// name = args[0]
ref
=
args
[
1
]
pstr
=
args
[
1
]
res
.
SetError
(
errors
.
New
(
"keychains not yet implemented"
),
cmds
.
ErrNormal
)
case
1
:
// name = n.Identity.ID.String()
ref
=
args
[
0
]
pstr
=
args
[
0
]
}
node
,
err
:=
n
.
Resolver
.
ResolvePath
(
path
.
FromString
(
pstr
))
if
err
!=
nil
{
res
.
SetError
(
fmt
.
Errorf
(
"failed to resolve path: %v"
,
err
),
cmds
.
ErrNormal
)
return
}
key
,
err
:=
node
.
Key
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
// TODO n.Keychain.Get(name).PrivKey
output
,
err
:=
publish
(
n
,
n
.
PrivateKey
,
ref
)
output
,
err
:=
publish
(
n
,
n
.
PrivateKey
,
key
.
Pretty
()
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
...
...
test/sharness/lib/test-lib-hashes.sh
浏览文件 @
97e1c953
...
...
@@ -2,4 +2,5 @@
# thus they can be defined + changed in one place
HASH_WELCOME_DOCS
=
"Qmcqtw8FfrVSBaRmbWwHxt3AuySBhJLcvmFYi3Lbc4xnwj"
HASH_HELP_PAGE
=
"QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7"
HASH_EMPTY_DIR
=
"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"
test/sharness/t0100-name.sh
浏览文件 @
97e1c953
...
...
@@ -10,24 +10,46 @@ test_description="Test ipfs repo operations"
test_init_ipfs
# test publishing a hash
test_expect_success
"'ipfs name publish' succeeds"
'
PEERID=`ipfs id -format="<id>"` &&
HASH=QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB &&
ipfs name publish $HASH > publish_out
ipfs name publish "$HASH_WELCOME_DOCS" >publish_out
'
test_expect_success
"publish output looks good"
'
echo
Published name $PEERID to $HASH >
expected1 &&
echo
"Published name $PEERID to $HASH_WELCOME_DOCS" >
expected1 &&
test_cmp publish_out expected1
'
test_expect_success
"'ipfs name resolve' succeeds"
'
ipfs name resolve
$PEERID >
output
ipfs name resolve
"$PEERID" >
output
'
test_expect_success
"resolve output looks good"
'
printf "%s"
$HASH >
expected2 &&
printf "%s"
"$HASH_WELCOME_DOCS" >
expected2 &&
test_cmp output expected2
'
# now test with a path
test_expect_success
"'ipfs name publish' succeeds"
'
PEERID=`ipfs id -format="<id>"` &&
ipfs name publish "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out
'
test_expect_success
"publish a path looks good"
'
echo "Published name $PEERID to $HASH_HELP_PAGE" >expected3 &&
test_cmp publish_out expected3
'
test_expect_success
"'ipfs name resolve' succeeds"
'
ipfs name resolve "$PEERID" >output
'
test_expect_success
"resolve output looks good"
'
printf "%s" "$HASH_HELP_PAGE" >expected4 &&
test_cmp output expected4
'
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论