From d83e07ea90a4a0cf1a1a5c0fa95b1158aff7f9dc Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 10 Feb 2020 11:29:51 +0000 Subject: [PATCH] wip: minimal plugin works License: MIT Signed-off-by: Oli Evans --- plugin/loader/preload.go | 2 ++ plugin/loader/preload_list | 1 + plugin/plugins/peeridlog/peeridlog.go | 44 +++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 plugin/plugins/peeridlog/peeridlog.go diff --git a/plugin/loader/preload.go b/plugin/loader/preload.go index 2c6d512bf..4c6209a11 100644 --- a/plugin/loader/preload.go +++ b/plugin/loader/preload.go @@ -5,6 +5,7 @@ import ( pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/flatfs" pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git" pluginlevelds "github.com/ipfs/go-ipfs/plugin/plugins/levelds" + pluginpeeridlog "github.com/ipfs/go-ipfs/plugin/plugins/peeridlog" ) // DO NOT EDIT THIS FILE @@ -16,4 +17,5 @@ func init() { Preload(pluginbadgerds.Plugins...) Preload(pluginflatfs.Plugins...) Preload(pluginlevelds.Plugins...) + Preload(pluginpeeridlog.Plugins...) } diff --git a/plugin/loader/preload_list b/plugin/loader/preload_list index 509ea5a22..d92a4a612 100644 --- a/plugin/loader/preload_list +++ b/plugin/loader/preload_list @@ -8,3 +8,4 @@ ipldgit github.com/ipfs/go-ipfs/plugin/plugins/git * badgerds github.com/ipfs/go-ipfs/plugin/plugins/badgerds * flatfs github.com/ipfs/go-ipfs/plugin/plugins/flatfs * levelds github.com/ipfs/go-ipfs/plugin/plugins/levelds * +peeridlog github.com/ipfs/go-ipfs/plugin/plugins/peeridlog * diff --git a/plugin/plugins/peeridlog/peeridlog.go b/plugin/plugins/peeridlog/peeridlog.go new file mode 100644 index 000000000..2117303af --- /dev/null +++ b/plugin/plugins/peeridlog/peeridlog.go @@ -0,0 +1,44 @@ +package peeridlog + +import ( + "fmt" + + core "github.com/ipfs/go-ipfs/core" + plugin "github.com/ipfs/go-ipfs/plugin" +) + +// Plugins is exported list of plugins that will be loaded +var Plugins = []plugin.Plugin{ + &peerIDLogPlugin{}, +} + +// Log all the PeerIDs we connect to. +type peerIDLogPlugin struct{} + +var _ plugin.PluginDaemonInternal = (*peerIDLogPlugin)(nil) + +// Name returns the plugin's name, satisfying the plugin.Plugin interface. +func (*peerIDLogPlugin) Name() string { + return "peeridlog" +} + +// Version returns the plugin's version, satisfying the plugin.Plugin interface. +func (*peerIDLogPlugin) Version() string { + return "0.1.0" +} + +// Init initializes plugin, satisfying the plugin.Plugin interface. Put any +// initialization logic here. +func (*peerIDLogPlugin) Init(*plugin.Environment) error { + return nil +} + +func (*peerIDLogPlugin) Start(*core.IpfsNode) error { + fmt.Println("peerIDLogPlugin HELLO!") + return nil +} + +func (*peerIDLogPlugin) Close() error { + fmt.Println("peerIDLogPlugin GOODBYE!") + return nil +}