wip: minimal plugin works
License: MIT Signed-off-by: Oli Evans <oli@tableflip.io>
Oli Evans committed
Feb 10, 2020 at 11:29 UTC
d83e07ea90a4a0cf1a1a5c0fa95b1158aff7f9dc
3 files changed
+47
plugin/loader/preload.go
+2
@@ -5,6 +5,7 @@ import (
5
pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/flatfs"
6
pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git"
7
pluginlevelds "github.com/ipfs/go-ipfs/plugin/plugins/levelds"
8
+ pluginpeeridlog "github.com/ipfs/go-ipfs/plugin/plugins/peeridlog"
9
)
10
11
// DO NOT EDIT THIS FILE
@@ -16,4 +17,5 @@ func init() {
17
Preload(pluginbadgerds.Plugins...)
18
Preload(pluginflatfs.Plugins...)
19
Preload(pluginlevelds.Plugins...)
20
+ Preload(pluginpeeridlog.Plugins...)
21
}
plugin/loader/preload_list
+1
@@ -8,3 +8,4 @@ ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git *
8
badgerds github.com/ipfs/go-ipfs/plugin/plugins/badgerds *
9
flatfs github.com/ipfs/go-ipfs/plugin/plugins/flatfs *
10
levelds github.com/ipfs/go-ipfs/plugin/plugins/levelds *
11
+peeridlog github.com/ipfs/go-ipfs/plugin/plugins/peeridlog *
plugin/plugins/peeridlog/peeridlog.go
new
+44
@@ -0,0 +1,44 @@
1
+package peeridlog
2
+
3
+import (
4
+ "fmt"
5
+
6
+ core "github.com/ipfs/go-ipfs/core"
7
+ plugin "github.com/ipfs/go-ipfs/plugin"
8
+)
9
+
10
+// Plugins is exported list of plugins that will be loaded
11
+var Plugins = []plugin.Plugin{
12
+ &peerIDLogPlugin{},
13
+}
14
+
15
+// Log all the PeerIDs we connect to.
16
+type peerIDLogPlugin struct{}
17
+
18
+var _ plugin.PluginDaemonInternal = (*peerIDLogPlugin)(nil)
19
+
20
+// Name returns the plugin's name, satisfying the plugin.Plugin interface.
21
+func (*peerIDLogPlugin) Name() string {
22
+ return "peeridlog"
23
+}
24
+
25
+// Version returns the plugin's version, satisfying the plugin.Plugin interface.
26
+func (*peerIDLogPlugin) Version() string {
27
+ return "0.1.0"
28
+}
29
+
30
+// Init initializes plugin, satisfying the plugin.Plugin interface. Put any
31
+// initialization logic here.
32
+func (*peerIDLogPlugin) Init(*plugin.Environment) error {
33
+ return nil
34
+}
35
+
36
+func (*peerIDLogPlugin) Start(*core.IpfsNode) error {
37
+ fmt.Println("peerIDLogPlugin HELLO!")
38
+ return nil
39
+}
40
+
41
+func (*peerIDLogPlugin) Close() error {
42
+ fmt.Println("peerIDLogPlugin GOODBYE!")
43
+ return nil
44
+}