Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
6044d2ae
提交
6044d2ae
authored
12月 19, 2018
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi offline: Address review
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
190728f0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
11 行增加
和
13 行删除
+11
-13
coreapi.go
core/coreapi/coreapi.go
+4
-6
dht.go
core/coreapi/dht.go
+3
-3
name.go
core/coreapi/name.go
+3
-3
pubsub.go
core/coreapi/pubsub.go
+1
-1
没有找到文件。
core/coreapi/coreapi.go
浏览文件 @
6044d2ae
...
@@ -67,10 +67,8 @@ type CoreAPI struct {
...
@@ -67,10 +67,8 @@ type CoreAPI struct {
pubSub
*
pubsub
.
PubSub
pubSub
*
pubsub
.
PubSub
// TODO: this can be generalized to all functions when we implement some
checkPublishAllowed
func
()
error
// api based security mechanism
checkOnline
func
(
allowOffline
bool
)
error
isPublishAllowed
func
()
error
isOnline
func
(
allowOffline
bool
)
error
// ONLY for re-applying options in WithOptions, DO NOT USE ANYWHERE ELSE
// ONLY for re-applying options in WithOptions, DO NOT USE ANYWHERE ELSE
nd
*
core
.
IpfsNode
nd
*
core
.
IpfsNode
...
@@ -178,14 +176,14 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
...
@@ -178,14 +176,14 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
parentOpts
:
settings
,
parentOpts
:
settings
,
}
}
subApi
.
is
Online
=
func
(
allowOffline
bool
)
error
{
subApi
.
check
Online
=
func
(
allowOffline
bool
)
error
{
if
!
n
.
OnlineMode
()
&&
!
allowOffline
{
if
!
n
.
OnlineMode
()
&&
!
allowOffline
{
return
coreiface
.
ErrOffline
return
coreiface
.
ErrOffline
}
}
return
nil
return
nil
}
}
subApi
.
is
PublishAllowed
=
func
()
error
{
subApi
.
check
PublishAllowed
=
func
()
error
{
if
n
.
Mounts
.
Ipns
!=
nil
&&
n
.
Mounts
.
Ipns
.
IsActive
()
{
if
n
.
Mounts
.
Ipns
!=
nil
&&
n
.
Mounts
.
Ipns
.
IsActive
()
{
return
errors
.
New
(
"cannot manually publish while IPNS is mounted"
)
return
errors
.
New
(
"cannot manually publish while IPNS is mounted"
)
}
}
...
...
core/coreapi/dht.go
浏览文件 @
6044d2ae
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
type
DhtAPI
CoreAPI
type
DhtAPI
CoreAPI
func
(
api
*
DhtAPI
)
FindPeer
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
pstore
.
PeerInfo
,
error
)
{
func
(
api
*
DhtAPI
)
FindPeer
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
pstore
.
PeerInfo
,
error
)
{
err
:=
api
.
is
Online
(
false
)
err
:=
api
.
check
Online
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
pstore
.
PeerInfo
{},
err
return
pstore
.
PeerInfo
{},
err
}
}
...
@@ -40,7 +40,7 @@ func (api *DhtAPI) FindProviders(ctx context.Context, p coreiface.Path, opts ...
...
@@ -40,7 +40,7 @@ func (api *DhtAPI) FindProviders(ctx context.Context, p coreiface.Path, opts ...
return
nil
,
err
return
nil
,
err
}
}
err
=
api
.
is
Online
(
false
)
err
=
api
.
check
Online
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -65,7 +65,7 @@ func (api *DhtAPI) Provide(ctx context.Context, path coreiface.Path, opts ...cao
...
@@ -65,7 +65,7 @@ func (api *DhtAPI) Provide(ctx context.Context, path coreiface.Path, opts ...cao
return
err
return
err
}
}
err
=
api
.
is
Online
(
false
)
err
=
api
.
check
Online
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
core/coreapi/name.go
浏览文件 @
6044d2ae
...
@@ -36,7 +36,7 @@ func (e *ipnsEntry) Value() coreiface.Path {
...
@@ -36,7 +36,7 @@ func (e *ipnsEntry) Value() coreiface.Path {
// Publish announces new IPNS name and returns the new IPNS entry.
// Publish announces new IPNS name and returns the new IPNS entry.
func
(
api
*
NameAPI
)
Publish
(
ctx
context
.
Context
,
p
coreiface
.
Path
,
opts
...
caopts
.
NamePublishOption
)
(
coreiface
.
IpnsEntry
,
error
)
{
func
(
api
*
NameAPI
)
Publish
(
ctx
context
.
Context
,
p
coreiface
.
Path
,
opts
...
caopts
.
NamePublishOption
)
(
coreiface
.
IpnsEntry
,
error
)
{
if
err
:=
api
.
is
PublishAllowed
();
err
!=
nil
{
if
err
:=
api
.
check
PublishAllowed
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -45,7 +45,7 @@ func (api *NameAPI) Publish(ctx context.Context, p coreiface.Path, opts ...caopt
...
@@ -45,7 +45,7 @@ func (api *NameAPI) Publish(ctx context.Context, p coreiface.Path, opts ...caopt
return
nil
,
err
return
nil
,
err
}
}
err
=
api
.
is
Online
(
options
.
AllowOffline
)
err
=
api
.
check
Online
(
options
.
AllowOffline
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -87,7 +87,7 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
...
@@ -87,7 +87,7 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
return
nil
,
err
return
nil
,
err
}
}
err
=
api
.
is
Online
(
true
)
err
=
api
.
check
Online
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
core/coreapi/pubsub.go
浏览文件 @
6044d2ae
...
@@ -127,7 +127,7 @@ func (api *PubSubAPI) checkNode() (routing.IpfsRouting, error) {
...
@@ -127,7 +127,7 @@ func (api *PubSubAPI) checkNode() (routing.IpfsRouting, error) {
return
nil
,
errors
.
New
(
"experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use."
)
return
nil
,
errors
.
New
(
"experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use."
)
}
}
err
:=
api
.
is
Online
(
false
)
err
:=
api
.
check
Online
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论