Skip to content
Snippets Groups Projects
Select Git revision
  • 0a3d16c518a48567cab17035249c241c47c97932
  • 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

Blame
  • user avatar
    Hans Moog authored
    0a3d16c5
    History
    plugin.go 1.86 KiB
    package autopeering
    
    import (
        "github.com/iotaledger/goshimmer/packages/daemon"
        "github.com/iotaledger/goshimmer/packages/node"
        "github.com/iotaledger/goshimmer/plugins/autopeering/instances"
        "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers"
        "github.com/iotaledger/goshimmer/plugins/autopeering/protocol"
        "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer"
        "github.com/iotaledger/goshimmer/plugins/autopeering/types/request"
        "github.com/iotaledger/goshimmer/plugins/autopeering/types/response"
        "github.com/iotaledger/goshimmer/plugins/autopeering/server"
        "github.com/iotaledger/goshimmer/plugins/gossip/neighbormanager"
    )
    
    func configure(plugin *node.Plugin) {
        instances.Configure(plugin)
        server.Configure(plugin)
        protocol.Configure(plugin)
    
        daemon.Events.Shutdown.Attach(func() {
            server.Shutdown(plugin)
        })
    
        protocol.Events.IncomingRequestAccepted.Attach(func(req *request.Request) {
            if neighbormanager.ACCEPTED_NEIGHBORS.AddOrUpdate(req.Issuer) {
                plugin.LogSuccess("new neighbor accepted: " + req.Issuer.Address.String() + " / " + req.Issuer.Identity.StringIdentifier)
            }
        })
    
        protocol.Events.OutgoingRequestAccepted.Attach(func(res *response.Response) {
            if neighbormanager.CHOSEN_NEIGHBORS.AddOrUpdate(res.Issuer) {
                plugin.LogSuccess("new neighbor chosen: " + res.Issuer.Address.String() + " / " + res.Issuer.Identity.StringIdentifier)
            }
        })
    
        protocol.Events.DiscoverPeer.Attach(func(p *peer.Peer) {
            if knownpeers.INSTANCE.AddOrUpdate(p) {
                plugin.LogInfo("new peer detected: " + p.Address.String() + " / " + p.Identity.StringIdentifier)
            }
        })
    }
    
    func run(plugin *node.Plugin) {
        server.Run(plugin)
        protocol.Run(plugin)
    }
    
    var PLUGIN = node.NewPlugin("Auto Peering", configure, run)