diff --git a/.gitmodules b/.gitmodules index 38c720d5cddb746e8a184ebafb0d2f9e4c28f22b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "IOTAtangle"] - path = IOTAtangle - url = https://github.com/glumb/IOTAtangle.git -[submodule "socket.io-client"] - path = socket.io-client - url = https://github.com/socketio/socket.io-client.git diff --git a/IOTAtangle b/IOTAtangle deleted file mode 160000 index 07bba77a296a2d06277cdae56aa963abeeb5f66e..0000000000000000000000000000000000000000 --- a/IOTAtangle +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 07bba77a296a2d06277cdae56aa963abeeb5f66e diff --git a/README.md b/README.md index d59e024d8e61a84e87dcd8c65678a07513b21412..20389d1ee9be2ff9623fa694e1c2352e4ac2134e 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ If Go is installed, you should see the version that's installed. When you first run GoShimmer, the node starts running and tries to connects to neighbors, using the autopeering module. -To run other modules such as the `spammer` or the Glumb visualizer `graph`, you can configure GoShimmer to enable them through plugins. +To run other modules such as the `spammer`, you can configure GoShimmer to enable them through plugins. **Note:** For a list of all the available configuration parameters, you can run the following command: @@ -211,31 +211,6 @@ To access the dashboard, you can use your browser (the default address is `http:  -### Installing the Glumb visualizer - -The Glumb visualizer allows you to view the transactions in the network, using a web browser. - -1. Enable the `graph` plugin either in your `config.json` file or in the command line (`--node.enablePlugins=["graph"]`) - -2. If you're running GoShimmer with the precompiled executable file, do the following in the `goshimmer` directory: - - ```bash - git clone https://github.com/glumb/IOTAtangle.git - // only this version seems to be stable - cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e - cd ../ - git clone https://github.com/socketio/socket.io-client.git - ``` - -3. If you built the code from source, do the following in the `goshimmer` directory: - - ```bash - git submodule init - git submodule update - ``` - -To open the visualizer, run GoShimmer, and go to `127.0.0.1:8083` in a web browser. - ## Supporting the project If you want to contribute to the code, consider posting a [bug report](https://github.com/iotaledger/goshimmer/issues/new-issue), feature request or a [pull request](https://github.com/iotaledger/goshimmer/pulls/). diff --git a/config.default.json b/config.default.json index de416ecb1feb1c4d3cae756a132cf36bde034e43..6149594ab10bb9fafd6603a7fffdcd9d6bf197fe 100644 --- a/config.default.json +++ b/config.default.json @@ -37,13 +37,6 @@ "gossip": { "port": 14666 }, - "graph": { - "bindAddress": "127.0.0.1:8082", - "domain": "", - "networkName": "GoShimmer", - "socketIOPath": "socket.io-client/dist/socket.io.js", - "webrootPath": "IOTAtangle/webroot" - }, "logger": { "level": "info", "disableCaller": false, diff --git a/docker-compose.yml b/docker-compose.yml index 9b63d4341f3a4551679c9ce56ab98ba4fa8ba51f..ea8ae83fcd122e21dfd5c4cb24a86dd95ffa48ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,10 +21,8 @@ services: # autopeering: - "14626:14626/udp" # webAPI: - "8080:8080/tcp" # dashboard: - "8081:8081/tcp" - # graph: - "8082:8082/tcp" ports: - "14666:14666/tcp" - "14626:14626/udp" #- "8080:8080/tcp" #- "8081:8081/tcp" - #- "8082:8082/tcp" diff --git a/pluginmgr/ui/plugins.go b/pluginmgr/ui/plugins.go index 3a6f013278af7a580d5e0071e9cb9f61b6f4ab3d..0cb1418a869694682102adac11fa348d95722a32 100644 --- a/pluginmgr/ui/plugins.go +++ b/pluginmgr/ui/plugins.go @@ -2,11 +2,9 @@ package ui import ( "github.com/iotaledger/goshimmer/plugins/dashboard" - "github.com/iotaledger/goshimmer/plugins/graph" "github.com/iotaledger/hive.go/node" ) var PLUGINS = node.Plugins( dashboard.Plugin, - graph.Plugin, ) diff --git a/plugins/graph/README.md b/plugins/graph/README.md deleted file mode 100644 index da7c4ca7925aaed7a7177c4a9dc69d661f0178d1..0000000000000000000000000000000000000000 --- a/plugins/graph/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# How to install this plugin -- Run the following commands in this folder (or set `graph.socketioPath` and `graph.webrootPath` in your config if you want to use another path) - -```bash -git clone https://github.com/glumb/IOTAtangle.git -cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e -cd ../ -git clone https://github.com/socketio/socket.io-client.git -``` \ No newline at end of file diff --git a/plugins/graph/graph.go b/plugins/graph/graph.go deleted file mode 100644 index 50edac385bc31bc3f110443cf5e7981115f3f93f..0000000000000000000000000000000000000000 --- a/plugins/graph/graph.go +++ /dev/null @@ -1,145 +0,0 @@ -package graph - -import ( - "container/ring" - "fmt" - "strings" - - socketio "github.com/googollee/go-socket.io" - "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" - "github.com/iotaledger/iota.go/consts" - - "github.com/iotaledger/goshimmer/plugins/config" - - "github.com/iotaledger/hive.go/syncutils" -) - -const ( - MessageBufferSize = 1800 -) - -var ( - msgRingBuffer *ring.Ring // messages - snRingBuffer *ring.Ring // confirmed messages - msRingBuffer *ring.Ring // Milestones - - broadcastLock = syncutils.Mutex{} - msgRingBufferLock = syncutils.Mutex{} -) - -type wsMessage struct { - Hash string `json:"hash"` - Address string `json:"address"` - Value string `json:"value"` - Tag string `json:"tag"` - Timestamp string `json:"timestamp"` - CurrentIndex string `json:"current_index"` - LastIndex string `json:"last_index"` - Bundle string `json:"bundle_hash"` - TrunkMessageId string `json:"transaction_trunk"` - BranchMessageId string `json:"transaction_branch"` -} - -type wsMessageSn struct { - Hash string `json:"hash"` - Address string `json:"address"` - TrunkMessageId string `json:"transaction_trunk"` - BranchMessageId string `json:"transaction_branch"` - Bundle string `json:"bundle"` -} - -type wsConfig struct { - NetworkName string `json:"networkName"` -} - -func initRingBuffers() { - msgRingBuffer = ring.New(MessageBufferSize) - snRingBuffer = ring.New(MessageBufferSize) - msRingBuffer = ring.New(20) -} - -func onConnectHandler(s socketio.Conn) error { - infoMsg := "Graph client connection established" - if s != nil { - infoMsg = fmt.Sprintf("%s (ID: %v)", infoMsg, s.ID()) - } - log.Info(infoMsg) - socketioServer.JoinRoom("broadcast", s) - - config := &wsConfig{NetworkName: config.Node.GetString(CFG_NETWORK)} - - var initMsgs []*wsMessage - msgRingBuffer.Do(func(wsMsg interface{}) { - if wsMsg != nil { - initMsgs = append(initMsgs, wsMsg.(*wsMessage)) - } - }) - - var initSns []*wsMessageSn - snRingBuffer.Do(func(sn interface{}) { - if sn != nil { - initSns = append(initSns, sn.(*wsMessageSn)) - } - }) - - var initMs []string - msRingBuffer.Do(func(ms interface{}) { - if ms != nil { - initMs = append(initMs, ms.(string)) - } - }) - - s.Emit("config", config) - s.Emit("inittx", initMsgs) // needs to be 'tx' for now - s.Emit("initsn", initSns) - s.Emit("initms", initMs) - s.Emit("donation", "0") - s.Emit("donations", []int{}) - s.Emit("donation-address", "-") - - return nil -} - -func onErrorHandler(conn socketio.Conn, e error) { - errorMsg := "Graph meet error" - if e != nil { - errorMsg = fmt.Sprintf("%s: %s", errorMsg, e.Error()) - } - log.Error(errorMsg) -} - -func onDisconnectHandler(s socketio.Conn, msg string) { - infoMsg := "Graph client connection closed" - if s != nil { - infoMsg = fmt.Sprintf("%s (ID: %v)", infoMsg, s.ID()) - } - log.Info(fmt.Sprintf("%s: %s", infoMsg, msg)) - socketioServer.LeaveAllRooms(s) -} - -var emptyTag = strings.Repeat("9", consts.TagTrinarySize/3) - -func onAttachedMessage(msg *message.Message) { - wsMsg := &wsMessage{ - Hash: msg.Id().String(), - Address: "", - Value: "0", - Tag: emptyTag, - Timestamp: "0", - CurrentIndex: "0", - LastIndex: "0", - Bundle: consts.NullHashTrytes, - TrunkMessageId: msg.TrunkId().String(), - BranchMessageId: msg.BranchId().String(), - } - - msgRingBufferLock.Lock() - msgRingBuffer.Value = wsMsg - msgRingBuffer = msgRingBuffer.Next() - msgRingBufferLock.Unlock() - - broadcastLock.Lock() - // needs to use 'tx' for now - socketioServer.BroadcastToRoom("broadcast", "tx", wsMsg) - broadcastLock.Unlock() -} diff --git a/plugins/graph/parameters.go b/plugins/graph/parameters.go deleted file mode 100644 index 02cce4982b55c8a785630a7d41ddcf94f788defc..0000000000000000000000000000000000000000 --- a/plugins/graph/parameters.go +++ /dev/null @@ -1,22 +0,0 @@ -package graph - -import ( - "github.com/iotaledger/goshimmer/plugins/banner" - flag "github.com/spf13/pflag" -) - -const ( - CFG_WEBROOT = "graph.webrootPath" - CFG_SOCKET_IO = "graph.socketioPath" - CFG_DOMAIN = "graph.domain" - CFG_BIND_ADDRESS = "graph.bindAddress" - CFG_NETWORK = "graph.networkName" -) - -func init() { - flag.String(CFG_WEBROOT, "IOTAtangle/webroot", "Path to IOTA Tangle Visualiser webroot files") - flag.String(CFG_SOCKET_IO, "socket.io-client/dist/socket.io.js", "Path to socket.io.js") - flag.String(CFG_DOMAIN, "", "Set the domain on which IOTA Tangle Visualiser is served") - flag.String(CFG_BIND_ADDRESS, "127.0.0.1:8082", "the bind address for the IOTA Tangle Visualizer") - flag.String(CFG_NETWORK, banner.AppName, "Name of the network shown in IOTA Tangle Visualiser") -} diff --git a/plugins/graph/plugin.go b/plugins/graph/plugin.go deleted file mode 100644 index 46006acb44b219ab8d79f9a4f66faa4f1cf7160f..0000000000000000000000000000000000000000 --- a/plugins/graph/plugin.go +++ /dev/null @@ -1,149 +0,0 @@ -package graph - -import ( - "errors" - "net/http" - "time" - - "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" - "github.com/iotaledger/goshimmer/plugins/config" - "github.com/iotaledger/goshimmer/plugins/messagelayer" - - "golang.org/x/net/context" - - "github.com/iotaledger/goshimmer/packages/shutdown" - - engineio "github.com/googollee/go-engine.io" - "github.com/googollee/go-engine.io/transport" - "github.com/googollee/go-engine.io/transport/polling" - "github.com/googollee/go-engine.io/transport/websocket" - socketio "github.com/googollee/go-socket.io" - - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/workerpool" -) - -// PluginName is the name of the graph plugin. -const PluginName = "Graph" - -var ( - // Plugin is the plugin instance of the graph plugin. - Plugin = node.NewPlugin(PluginName, node.Disabled, configure, run) - - log *logger.Logger - - newMsgWorkerCount = 1 - newMsgWorkerQueueSize = 10000 - newMsgWorkerPool *workerpool.WorkerPool - - server *http.Server - router *http.ServeMux - socketioServer *socketio.Server -) - -func downloadSocketIOHandler(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, config.Node.GetString(CFG_SOCKET_IO)) -} - -func configureSocketIOServer() error { - var err error - - socketioServer, err = socketio.NewServer(&engineio.Options{ - PingTimeout: time.Second * 20, - PingInterval: time.Second * 5, - Transports: []transport.Transport{ - polling.Default, - websocket.Default, - }, - }) - if err != nil { - return err - } - - socketioServer.OnConnect("/", onConnectHandler) - socketioServer.OnError("/", onErrorHandler) - socketioServer.OnDisconnect("/", onDisconnectHandler) - - return nil -} - -func configure(plugin *node.Plugin) { - log = logger.NewLogger(PluginName) - initRingBuffers() - - router = http.NewServeMux() - - // socket.io and web server - server = &http.Server{ - Addr: config.Node.GetString(CFG_BIND_ADDRESS), - Handler: router, - } - - fs := http.FileServer(http.Dir(config.Node.GetString(CFG_WEBROOT))) - - if err := configureSocketIOServer(); err != nil { - log.Panicf("%v", err.Error()) - } - - router.Handle("/", fs) - router.HandleFunc("/socket.io/socket.io.js", downloadSocketIOHandler) - router.Handle("/socket.io/", socketioServer) - - newMsgWorkerPool = workerpool.New(func(task workerpool.Task) { - onAttachedMessage(task.Param(0).(*message.Message)) - task.Return(nil) - }, workerpool.WorkerCount(newMsgWorkerCount), workerpool.QueueSize(newMsgWorkerQueueSize)) -} - -func run(*node.Plugin) { - - onMessageAttached := events.NewClosure(func(msg *message.Message) { - newMsgWorkerPool.TrySubmit(msg) - }) - - daemon.BackgroundWorker("Graph[AttachedMessageWorker]", func(shutdownSignal <-chan struct{}) { - log.Info("Starting Graph[AttachedMessageWorker] ... done") - messagelayer.Tangle.Events.MessageAttached.Attach(onMessageAttached) - newMsgWorkerPool.Start() - <-shutdownSignal - messagelayer.Tangle.Events.MessageAttached.Detach(onMessageAttached) - newMsgWorkerPool.Stop() - log.Info("Stopping Graph[AttachedMessageWorker] ... done") - }, shutdown.PriorityGraph) - - daemon.BackgroundWorker("Graph Webserver", func(shutdownSignal <-chan struct{}) { - go socketioServer.Serve() - - stopped := make(chan struct{}) - go func() { - log.Infof("You can now access IOTA Tangle Visualiser using: http://%s", config.Node.GetString(CFG_BIND_ADDRESS)) - if err := server.ListenAndServe(); err != nil { - if !errors.Is(err, http.ErrServerClosed) { - log.Errorf("Error serving: %s", err) - } - } - close(stopped) - }() - - select { - case <-shutdownSignal: - case <-stopped: - } - - log.Info("Stopping Graph Webserver ...") - ctx, cancel := context.WithTimeout(context.Background(), time.Second) - defer cancel() - - if err := server.Shutdown(ctx); err != nil { - log.Errorf("Error stopping: %s", err) - } - - if err := socketioServer.Close(); err != nil { - log.Errorf("Error closing Socket.IO server: %s", err) - } - log.Info("Stopping Graph Webserver ... done") - }, shutdown.PriorityGraph) -} diff --git a/plugins/webapi/info/plugin.go b/plugins/webapi/info/plugin.go index 61f485cb0ccf524286dbf6b86899b979c99c4df1..2a858e75cd0e690dcebc4ddc91ee5e9f016176c6 100644 --- a/plugins/webapi/info/plugin.go +++ b/plugins/webapi/info/plugin.go @@ -49,7 +49,6 @@ func configure(_ *node.Plugin) { // "Logger" // ], // "disabledlugins":[ -// "Graph", // "RemoteLog", // "Spammer", // "WebAPI Auth" diff --git a/socket.io-client b/socket.io-client deleted file mode 160000 index 661f1e7fac2488b6d3d206f96bb59073c4c98b1c..0000000000000000000000000000000000000000 --- a/socket.io-client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 661f1e7fac2488b6d3d206f96bb59073c4c98b1c diff --git a/tools/docker-network/config.docker.json b/tools/docker-network/config.docker.json index 08ffcb36be20aeed1234a2ebf855647cdb2090d4..9826284f638cbace98fd11caaa1f95af5f054357 100644 --- a/tools/docker-network/config.docker.json +++ b/tools/docker-network/config.docker.json @@ -33,13 +33,6 @@ "gossip": { "port": 14666 }, - "graph": { - "bindAddress": "127.0.0.1:8082", - "domain": "", - "networkName": "GoShimmer", - "socketIOPath": "socket.io-client/dist/socket.io.js", - "webrootPath": "IOTAtangle/webroot" - }, "logger": { "level": "info", "disableCaller": false,