Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
2a9e5005
Unverified
提交
2a9e5005
authored
11月 22, 2019
作者:
Michael Muré
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
plugins: introduce PluginDaemonInternal to directly interact with IpfsNode
上级
b8ec598d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
8 行删除
+31
-8
daemon.go
cmd/ipfs/daemon.go
+1
-6
daemoninternal.go
plugin/daemoninternal.go
+14
-0
loader.go
plugin/loader/loader.go
+16
-2
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
2a9e5005
...
@@ -19,7 +19,6 @@ import (
...
@@ -19,7 +19,6 @@ import (
oldcmds
"github.com/ipfs/go-ipfs/commands"
oldcmds
"github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core"
commands
"github.com/ipfs/go-ipfs/core/commands"
commands
"github.com/ipfs/go-ipfs/core/commands"
coreapi
"github.com/ipfs/go-ipfs/core/coreapi"
corehttp
"github.com/ipfs/go-ipfs/core/corehttp"
corehttp
"github.com/ipfs/go-ipfs/core/corehttp"
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
libp2p
"github.com/ipfs/go-ipfs/core/node/libp2p"
libp2p
"github.com/ipfs/go-ipfs/core/node/libp2p"
...
@@ -368,11 +367,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
...
@@ -368,11 +367,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
// Start "core" plugins. We want to do this *before* starting the HTTP
// Start "core" plugins. We want to do this *before* starting the HTTP
// API as the user may be relying on these plugins.
// API as the user may be relying on these plugins.
api
,
err
:=
coreapi
.
NewCoreAPI
(
node
)
err
=
cctx
.
Plugins
.
Start
(
node
)
if
err
!=
nil
{
return
err
}
err
=
cctx
.
Plugins
.
Start
(
api
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
plugin/daemoninternal.go
0 → 100644
浏览文件 @
2a9e5005
package
plugin
import
"github.com/ipfs/go-ipfs/core"
// PluginDaemonInternal is an interface for daemon plugins. These plugins will be run on
// the daemon and will be given a direct access to the IpfsNode.
//
// Note: PluginDaemonInternal is considered internal and no guarantee is made concerning
// the stability of its API. If you can, use PluginAPI instead.
type
PluginDaemonInternal
interface
{
Plugin
Start
(
*
core
.
IpfsNode
)
error
}
plugin/loader/loader.go
浏览文件 @
2a9e5005
...
@@ -9,13 +9,15 @@ import (
...
@@ -9,13 +9,15 @@ import (
config
"github.com/ipfs/go-ipfs-config"
config
"github.com/ipfs/go-ipfs-config"
cserialize
"github.com/ipfs/go-ipfs-config/serialize"
cserialize
"github.com/ipfs/go-ipfs-config/serialize"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core/coreapi"
coredag
"github.com/ipfs/go-ipfs/core/coredag"
coredag
"github.com/ipfs/go-ipfs/core/coredag"
plugin
"github.com/ipfs/go-ipfs/plugin"
plugin
"github.com/ipfs/go-ipfs/plugin"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
ipld
"github.com/ipfs/go-ipld-format"
ipld
"github.com/ipfs/go-ipld-format"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
coreiface
"github.com/ipfs/interface-go-ipfs-core"
opentracing
"github.com/opentracing/opentracing-go"
opentracing
"github.com/opentracing/opentracing-go"
)
)
...
@@ -236,10 +238,14 @@ func (loader *PluginLoader) Inject() error {
...
@@ -236,10 +238,14 @@ func (loader *PluginLoader) Inject() error {
}
}
// Start starts all long-running plugins.
// Start starts all long-running plugins.
func
(
loader
*
PluginLoader
)
Start
(
iface
coreiface
.
CoreAPI
)
error
{
func
(
loader
*
PluginLoader
)
Start
(
node
*
core
.
IpfsNode
)
error
{
if
err
:=
loader
.
transition
(
loaderInjected
,
loaderStarting
);
err
!=
nil
{
if
err
:=
loader
.
transition
(
loaderInjected
,
loaderStarting
);
err
!=
nil
{
return
err
return
err
}
}
iface
,
err
:=
coreapi
.
NewCoreAPI
(
node
)
if
err
!=
nil
{
return
err
}
for
_
,
pl
:=
range
loader
.
plugins
{
for
_
,
pl
:=
range
loader
.
plugins
{
if
pl
,
ok
:=
pl
.
(
plugin
.
PluginDaemon
);
ok
{
if
pl
,
ok
:=
pl
.
(
plugin
.
PluginDaemon
);
ok
{
err
:=
pl
.
Start
(
iface
)
err
:=
pl
.
Start
(
iface
)
...
@@ -249,6 +255,14 @@ func (loader *PluginLoader) Start(iface coreiface.CoreAPI) error {
...
@@ -249,6 +255,14 @@ func (loader *PluginLoader) Start(iface coreiface.CoreAPI) error {
}
}
loader
.
started
=
append
(
loader
.
started
,
pl
)
loader
.
started
=
append
(
loader
.
started
,
pl
)
}
}
if
pl
,
ok
:=
pl
.
(
plugin
.
PluginDaemonInternal
);
ok
{
err
:=
pl
.
Start
(
node
)
if
err
!=
nil
{
_
=
loader
.
Close
()
return
err
}
loader
.
started
=
append
(
loader
.
started
,
pl
)
}
}
}
return
loader
.
transition
(
loaderStarting
,
loaderStarted
)
return
loader
.
transition
(
loaderStarting
,
loaderStarted
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论