Skip to content
Snippets Groups Projects
Select Git revision
  • d6e2383bd6d41cacb5a478faa8b01e55ff777b4c
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

plugin.go

  • plugin.go 1.19 KiB
    package spammer
    
    import (
    	"sync"
    
    	"github.com/iotaledger/goshimmer/packages/binary/spammer"
    	"github.com/iotaledger/goshimmer/packages/shutdown"
    	"github.com/iotaledger/goshimmer/plugins/issuer"
    	"github.com/iotaledger/goshimmer/plugins/webapi"
    	"github.com/iotaledger/hive.go/daemon"
    	"github.com/iotaledger/hive.go/logger"
    	"github.com/iotaledger/hive.go/node"
    )
    
    var messageSpammer *spammer.Spammer
    
    // PluginName is the name of the spammer plugin.
    const PluginName = "Spammer"
    
    var (
    	// plugin is the plugin instance of the spammer plugin.
    	plugin *node.Plugin
    	once   sync.Once
    	log    *logger.Logger
    )
    
    // Plugin gets the plugin instance.
    func Plugin() *node.Plugin {
    	once.Do(func() {
    		plugin = node.NewPlugin(PluginName, node.Disabled, configure, run)
    	})
    	return plugin
    }
    
    func configure(plugin *node.Plugin) {
    	log = logger.NewLogger(PluginName)
    	messageSpammer = spammer.New(issuer.IssuePayload)
    	webapi.Server().GET("spammer", handleRequest)
    }
    
    func run(*node.Plugin) {
    	if err := daemon.BackgroundWorker("Tangle", func(shutdownSignal <-chan struct{}) {
    		<-shutdownSignal
    
    		messageSpammer.Shutdown()
    	}, shutdown.PrioritySpammer); err != nil {
    		log.Panicf("Failed to start as daemon: %s", err)
    	}
    }