peergov

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutboundConnectionEventType = "peergov.outbound-conn"
	PeerDemotedEventType        = "peergov.peer-demoted"
	PeerPromotedEventType       = "peergov.peer-promoted"
	PeerRemovedEventType        = "peergov.peer-removed"
	PeerAddedEventType          = "peergov.peer-added"
)
View Source
const (
	PeerSourceUnknown               = 0
	PeerSourceTopologyLocalRoot     = 1
	PeerSourceTopologyPublicRoot    = 2
	PeerSourceTopologyBootstrapPeer = 3
	PeerSourceP2PLedger             = 4
	PeerSourceP2PGossip             = 5
	PeerSourceInboundConn           = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OutboundConnectionEvent

type OutboundConnectionEvent struct {
	ConnectionId ouroboros.ConnectionId
}

type Peer

type Peer struct {
	LastActivity   time.Time
	Connection     *PeerConnection
	Address        string
	ReconnectCount int
	ReconnectDelay time.Duration
	Source         PeerSource
	State          PeerState
	Sharable       bool
}

type PeerConnection added in v0.3.1

type PeerConnection struct {
	Id              ouroboros.ConnectionId
	VersionData     oprotocol.VersionData
	ProtocolVersion uint
	IsClient        bool
}

type PeerGovernor

type PeerGovernor struct {
	// contains filtered or unexported fields
}

func NewPeerGovernor

func NewPeerGovernor(cfg PeerGovernorConfig) *PeerGovernor

func (*PeerGovernor) AddPeer added in v0.18.0

func (p *PeerGovernor) AddPeer(address string, source PeerSource)

func (*PeerGovernor) GetPeers

func (p *PeerGovernor) GetPeers() []Peer

func (*PeerGovernor) LoadTopologyConfig

func (p *PeerGovernor) LoadTopologyConfig(
	topologyConfig *topology.TopologyConfig,
)

func (*PeerGovernor) SetPeerHotByConnId added in v0.18.0

func (p *PeerGovernor) SetPeerHotByConnId(connId ouroboros.ConnectionId)

func (*PeerGovernor) Start

func (p *PeerGovernor) Start() error

func (*PeerGovernor) Stop added in v0.18.0

func (p *PeerGovernor) Stop()

Stop gracefully shuts down the peer governor

type PeerGovernorConfig

type PeerGovernorConfig struct {
	PromRegistry         prometheus.Registerer
	Logger               *slog.Logger
	EventBus             *event.EventBus
	ConnManager          *connmanager.ConnectionManager
	PeerRequestFunc      func(peer *Peer) []string
	ReconcileInterval    time.Duration
	MaxReconnectFailures int
	MinHotPeers          int
	InactivityTimeout    time.Duration
	DisableOutbound      bool
}

type PeerSource

type PeerSource uint16

type PeerState added in v0.18.0

type PeerState uint16
const (
	PeerStateCold PeerState = iota
	PeerStateWarm
	PeerStateHot
)

type PeerStateChangeEvent added in v0.18.0

type PeerStateChangeEvent struct {
	Address string
	Reason  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL