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

autopeering.go

Blame
  • autopeering.go 5.56 KiB
    package autopeering
    
    import (
    	"errors"
    	"fmt"
    	"hash/fnv"
    	"net"
    	"strconv"
    	"strings"
    	"sync"
    
    	"github.com/iotaledger/goshimmer/plugins/autopeering/local"
    	"github.com/iotaledger/goshimmer/plugins/banner"
    	"github.com/iotaledger/goshimmer/plugins/config"
    	"github.com/iotaledger/hive.go/autopeering/discover"
    	"github.com/iotaledger/hive.go/autopeering/peer"
    	"github.com/iotaledger/hive.go/autopeering/peer/service"
    	"github.com/iotaledger/hive.go/autopeering/selection"
    	"github.com/iotaledger/hive.go/autopeering/server"
    	"github.com/iotaledger/hive.go/crypto/ed25519"
    	"github.com/iotaledger/hive.go/identity"
    	"github.com/iotaledger/hive.go/logger"
    	"github.com/mr-tron/base58"
    )
    
    // autopeering constants
    const (
    	ProtocolVersion = 0      // update on protocol changes
    	NetworkVersion  = "v0.2" // update on network changes
    )
    
    var (
    	// ErrParsingMasterNode is returned for an invalid master node.
    	ErrParsingMasterNode = errors.New("cannot parse master node")
    
    	// networkID specifies the autopeering network identifier.
    	networkID = hash32([]byte(banner.AppVersion + NetworkVersion))
    
    	// Conn contains the network connection.
    	Conn *NetConnMetric
    )
    
    var (
    	// the peer discovery protocol
    	peerDisc     *discover.Protocol
    	peerDiscOnce sync.Once
    
    	// the peer selection protocol
    	peerSel     *selection.Protocol
    	peerSelOnce sync.Once
    
    	// block until the peering server has been started
    	srvBarrier = struct {
    		once sync.Once
    		c    chan *server.Server
    	}{c: make(chan *server.Server, 1)}
    )
    
    // NetworkID gets the networkID.
    func NetworkID() uint32 {
    	return networkID
    }
    
    // Discovery returns the peer discovery instance.
    func Discovery() *discover.Protocol {
    	peerDiscOnce.Do(createPeerDisc)
    	return peerDisc
    }
    
    // Selection returns the neighbor selection instance.