Skip to content
Snippets Groups Projects
Commit bd602472 authored by Samuelle MOLLARD's avatar Samuelle MOLLARD
Browse files

modified: core.go

	modified:   tutorial/plugin.go
	modified:   ../tools/docker-network/docker-compose.yml

Allows for code to be executed (soon i guess)
parent e7a87fb1
No related branches found
No related tags found
1 merge request!1V data collection
...@@ -23,10 +23,12 @@ import ( ...@@ -23,10 +23,12 @@ import (
"github.com/iotaledger/goshimmer/plugins/syncbeacon" "github.com/iotaledger/goshimmer/plugins/syncbeacon"
"github.com/iotaledger/goshimmer/plugins/syncbeaconfollower" "github.com/iotaledger/goshimmer/plugins/syncbeaconfollower"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"goshimmer/plugins/tutorial"
) )
// Core contains the core plugins of a GoShimmer node. // Core contains the core plugins of a GoShimmer node.
var Core = node.Plugins( var Core = node.Plugins(
tutorial.Plugin(),
banner.Plugin(), banner.Plugin(),
config.Plugin(), config.Plugin(),
logger.Plugin(), logger.Plugin(),
......
...@@ -2,6 +2,8 @@ package tutorial ...@@ -2,6 +2,8 @@ package tutorial
import ( import (
"sync" "sync"
"os"
"fmt"
"github.com/iotaledger/goshimmer/packages/tangle" "github.com/iotaledger/goshimmer/packages/tangle"
"github.com/iotaledger/goshimmer/plugins/messagelayer" "github.com/iotaledger/goshimmer/plugins/messagelayer"
...@@ -26,17 +28,22 @@ var ( ...@@ -26,17 +28,22 @@ var (
// Plugin gets the plugin instance. // Plugin gets the plugin instance.
func Plugin() *node.Plugin { func Plugin() *node.Plugin {
pluginOnce.Do(func() { pluginOnce.Do(func() {
plugin = node.NewPlugin(PluginName, node.Disabled, configure, run) plugin = node.NewPlugin(PluginName, node.Enabled, configure, run)
}) })
return plugin return plugin
} }
func configure(*node.Plugin) { func configure(*node.Plugin) {
write_to_file("timestamp;msg_id;msg_payload_type\n")
log = logger.NewLogger(PluginName) log = logger.NewLogger(PluginName)
messagelayer.Tangle().Events.MessageSolid.Attach(events.NewClosure(func(cachedMsgEvent *tangle.CachedMessageEvent) { messagelayer.Tangle().Events.MessageSolid.Attach(events.NewClosure(func(cachedMsgEvent *tangle.CachedMessageEvent) {
defer cachedMsgEvent.MessageMetadata.Release() defer cachedMsgEvent.MessageMetadata.Release()
cachedMsgEvent.Message.Consume(func(message *tangle.Message) { cachedMsgEvent.Message.Consume(func(message *tangle.Message) {
log.Info(message.IssuingTime().UnixNano(), message.ID(), "-->", message.StrongParents(), message.WeakParents()) to_write := fmt.Sprintf("%d;%d;%d\n", message.IssuingTime().UnixNano(), message.ID(), message.Payload().Type())
write_to_file(to_write)
path, _ := os.Getwd()
log.Info("The path to the current workdir is : ", path)
log.Info(message.IssuingTime().UnixNano(), message.ID(), message.StrongParents(), message.WeakParents())
}) })
})) }))
...@@ -45,6 +52,16 @@ func configure(*node.Plugin) { ...@@ -45,6 +52,16 @@ func configure(*node.Plugin) {
})) }))
} }
func write_to_file(text_to_append string) {
f, _ := os.OpenFile("/tmp/data.csv",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
defer f.Close()
f.WriteString(text_to_append)
}
func run(*node.Plugin) { func run(*node.Plugin) {
log.Infof("Starting %s ...", PluginName) log.Infof("Starting %s ...", PluginName)
path, _ := os.Getwd()
log.Infof(path)
write_to_file("timestamp;msg_id;msg_payload_type\n")
} }
...@@ -65,7 +65,7 @@ services: ...@@ -65,7 +65,7 @@ services:
command: > command: >
--config=/tmp/config.json --config=/tmp/config.json
--database.directory=/tmp/mainnetdb --database.directory=/tmp/mainnetdb
--node.enablePlugins=bootstrap,spammer --node.enablePlugins=bootstrap,spammer,tutorial
--valueLayer.snapshot.file=/tmp/assets/7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih.bin --valueLayer.snapshot.file=/tmp/assets/7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih.bin
--node.disablePlugins=portcheck,clock --node.disablePlugins=portcheck,clock
--syncbeaconfollower.followNodes=EYsaGXnUVA9aTYL9FwYEvoQ8d1HCJveQVL7vogu6pqCP --syncbeaconfollower.followNodes=EYsaGXnUVA9aTYL9FwYEvoQ8d1HCJveQVL7vogu6pqCP
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment