peer_manager

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSkipFilter added in v0.10.0

func NewSkipFilter(list *messages.SkipMessageList) conn.SkipFilter

Types

type DuplicateChecker added in v0.8.1

type DuplicateChecker interface {
	Add([]byte) bool
}

type PeerManager

type PeerManager interface {
	NewConnection(peer.Peer) error
	ConnectedCount() int
	EachConnected(func(peer.Peer, *proto.Score))
	Suspend(peer peer.Peer, suspendTime time.Time, reason string)
	Suspended() []storage.SuspendedPeer
	AddToBlackList(peer peer.Peer, blockTime time.Time, reason string)
	BlackList() []storage.BlackListedPeer
	ClearBlackList() error
	UpdateScore(p peer.Peer, score *proto.Score) error
	KnownPeers() []storage.KnownPeer
	UpdateKnownPeers([]storage.KnownPeer) error
	Close()
	SpawnOutgoingConnections(context.Context)
	SpawnIncomingConnection(ctx context.Context, conn net.Conn) error
	Spawned() []proto.IpPort
	Connect(context.Context, proto.TCPAddr) error
	Score(p peer.Peer) (*proto.Score, error)

	// AskPeers sends GetPeersMessage message to all connected nodes.
	AskPeers()

	GetPeerWithMaxScore() (peer.Peer, error)

	Disconnect(peer.Peer)
}

type PeerManagerImpl

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

func NewPeerManager

func NewPeerManager(spawner PeerSpawner, storage PeerStorage, limitConnections int, version proto.Version,
	networkName string, enableOutboundConnections bool, newConnectionsLimit int) *PeerManagerImpl

func (*PeerManagerImpl) AddAddress

func (a *PeerManagerImpl) AddAddress(ctx context.Context, addr proto.TCPAddr) error

func (*PeerManagerImpl) AddToBlackList added in v0.10.2

func (a *PeerManagerImpl) AddToBlackList(p peer.Peer, blockTime time.Time, reason string)

func (*PeerManagerImpl) AskPeers

func (a *PeerManagerImpl) AskPeers()

func (*PeerManagerImpl) BlackList added in v0.10.2

func (a *PeerManagerImpl) BlackList() []storage.BlackListedPeer

func (*PeerManagerImpl) ClearBlackList added in v0.10.2

func (a *PeerManagerImpl) ClearBlackList() error

func (*PeerManagerImpl) Close

func (a *PeerManagerImpl) Close()

func (*PeerManagerImpl) Connect

func (a *PeerManagerImpl) Connect(ctx context.Context, addr proto.TCPAddr) error

func (*PeerManagerImpl) ConnectedCount added in v0.5.0

func (a *PeerManagerImpl) ConnectedCount() int

func (*PeerManagerImpl) Disconnect

func (a *PeerManagerImpl) Disconnect(p peer.Peer)

func (*PeerManagerImpl) EachConnected

func (a *PeerManagerImpl) EachConnected(f func(peer peer.Peer, score *big.Int))

func (*PeerManagerImpl) GetPeerWithMaxScore added in v0.10.0

func (a *PeerManagerImpl) GetPeerWithMaxScore() (peer.Peer, error)

func (*PeerManagerImpl) KnownPeers

func (a *PeerManagerImpl) KnownPeers() []storage.KnownPeer

func (*PeerManagerImpl) NewConnection added in v0.5.0

func (a *PeerManagerImpl) NewConnection(p peer.Peer) error

func (*PeerManagerImpl) Run

func (a *PeerManagerImpl) Run(ctx context.Context)

func (*PeerManagerImpl) Score

func (a *PeerManagerImpl) Score(p peer.Peer) (*proto.Score, error)

func (*PeerManagerImpl) SpawnIncomingConnection

func (a *PeerManagerImpl) SpawnIncomingConnection(ctx context.Context, conn net.Conn) error

func (*PeerManagerImpl) SpawnOutgoingConnections

func (a *PeerManagerImpl) SpawnOutgoingConnections(ctx context.Context)

func (*PeerManagerImpl) Spawned

func (a *PeerManagerImpl) Spawned() []proto.IpPort

func (*PeerManagerImpl) Suspend

func (a *PeerManagerImpl) Suspend(p peer.Peer, suspendTime time.Time, reason string)

func (*PeerManagerImpl) Suspended

func (a *PeerManagerImpl) Suspended() []storage.SuspendedPeer

func (*PeerManagerImpl) UpdateKnownPeers

func (a *PeerManagerImpl) UpdateKnownPeers(known []storage.KnownPeer) error

func (*PeerManagerImpl) UpdateScore

func (a *PeerManagerImpl) UpdateScore(p peer.Peer, score *big.Int) error

type PeerSpawner

type PeerSpawner interface {
	SpawnOutgoing(ctx context.Context, addr proto.TCPAddr) error
	SpawnIncoming(ctx context.Context, c net.Conn) error
}

type PeerSpawnerImpl

type PeerSpawnerImpl struct {
	DuplicateChecker DuplicateChecker
	// contains filtered or unexported fields
}

func NewPeerSpawner

func NewPeerSpawner(parent peer.Parent, WavesNetwork string, declAddr proto.TCPAddr, nodeName string, nodeNonce uint64, version proto.Version) *PeerSpawnerImpl

func (*PeerSpawnerImpl) SpawnIncoming

func (a *PeerSpawnerImpl) SpawnIncoming(ctx context.Context, c net.Conn) error

func (*PeerSpawnerImpl) SpawnOutgoing

func (a *PeerSpawnerImpl) SpawnOutgoing(ctx context.Context, address proto.TCPAddr) error

type PeerStorage

type PeerStorage interface {
	Known(limit int) []storage.KnownPeer
	AddOrUpdateKnown(known []storage.KnownPeer, now time.Time) error
	DeleteKnown(known []storage.KnownPeer) error
	DropKnown() error

	Suspended(now time.Time) []storage.SuspendedPeer
	AddSuspended(suspended []storage.SuspendedPeer) error
	IsSuspendedIP(ip storage.IP, now time.Time) bool
	IsSuspendedIPs(ips []storage.IP, now time.Time) []bool
	DeleteSuspendedByIP(suspended []storage.SuspendedPeer) error
	RefreshSuspended(now time.Time) error
	DropSuspended() error

	BlackList(now time.Time) []storage.BlackListedPeer
	AddToBlackList(blackListed []storage.BlackListedPeer) error
	IsBlackListedIP(ip storage.IP, now time.Time) bool
	IsBlackListedIPs(ips []storage.IP, now time.Time) []bool
	DeleteBlackListedByIP(blackListed []storage.BlackListedPeer) error
	RefreshBlackList(now time.Time) error
	DropBlackList() error

	DropStorage() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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