peerManager

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// The number of peers to return when querying for peers
	C_peerCount = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicPeerManager

type BasicPeerManager struct {
	*basicConnGater.BasicConnectionGater
	*basicConnMgr.BasicConnMgr
	// contains filtered or unexported fields
}

func (*BasicPeerManager) BanPeer

func (pm *BasicPeerManager) BanPeer(peer p2p.PeerID)

func (*BasicPeerManager) ClosePendingRequest

func (pm *BasicPeerManager) ClosePendingRequest(peer p2p.PeerID) error

func (*BasicPeerManager) CloseStream

func (pm *BasicPeerManager) CloseStream(peerID p2p.PeerID) error

func (*BasicPeerManager) GetHost

func (pm *BasicPeerManager) GetHost() host.Host

func (*BasicPeerManager) GetPeers

func (pm *BasicPeerManager) GetPeers(topic *pubsubManager.Topic, quality PeerQuality) map[p2p.PeerID]struct{}

func (*BasicPeerManager) GetSelfID

func (pm *BasicPeerManager) GetSelfID() p2p.PeerID

func (*BasicPeerManager) GetStream

func (pm *BasicPeerManager) GetStream(peerID p2p.PeerID) (network.Stream, error)

func (*BasicPeerManager) MarkLatentPeer

func (pm *BasicPeerManager) MarkLatentPeer(peer p2p.PeerID, topic *pubsubManager.Topic)

func (*BasicPeerManager) MarkLivelyPeer

func (pm *BasicPeerManager) MarkLivelyPeer(peer p2p.PeerID, topic *pubsubManager.Topic)

func (*BasicPeerManager) MarkResponsivePeer

func (pm *BasicPeerManager) MarkResponsivePeer(peer p2p.PeerID, topic *pubsubManager.Topic)

func (*BasicPeerManager) MarkUnresponsivePeer

func (pm *BasicPeerManager) MarkUnresponsivePeer(peer p2p.PeerID, topic *pubsubManager.Topic)

func (*BasicPeerManager) ProtectPeer

func (pm *BasicPeerManager) ProtectPeer(peer p2p.PeerID)

func (*BasicPeerManager) Provide

func (pm *BasicPeerManager) Provide(ctx context.Context, location common.Location, data interface{}) error

func (*BasicPeerManager) RemovePeer

func (pm *BasicPeerManager) RemovePeer(peerID p2p.PeerID) error

func (*BasicPeerManager) SetDHT

func (pm *BasicPeerManager) SetDHT(dht *dual.DHT)

func (*BasicPeerManager) SetHost

func (pm *BasicPeerManager) SetHost(host host.Host)

func (*BasicPeerManager) SetP2PBackend

func (pm *BasicPeerManager) SetP2PBackend(p2pnode protocol.QuaiP2PNode)

Set the host for the stream manager

func (*BasicPeerManager) SetSelfID

func (pm *BasicPeerManager) SetSelfID(selfID p2p.PeerID)

func (*BasicPeerManager) SetStreamManager

func (pm *BasicPeerManager) SetStreamManager(streamManager streamManager.StreamManager)

Implementation of underlying StreamManager interface

func (*BasicPeerManager) Stop

func (pm *BasicPeerManager) Stop() error

func (*BasicPeerManager) UnprotectPeer

func (pm *BasicPeerManager) UnprotectPeer(peer p2p.PeerID)

func (*BasicPeerManager) WriteMessageToStream

func (pm *BasicPeerManager) WriteMessageToStream(peerId p2p.PeerID, stream network.Stream, msg []byte) error

type PeerManager

type PeerManager interface {
	connmgr.ConnManager
	connmgr.ConnectionGater
	streamManager.StreamManager

	BlockAddr(ip net.IP) error
	BlockPeer(p peer.ID) error
	BlockSubnet(ipnet *net.IPNet) error
	ListBlockedAddrs() []net.IP
	ListBlockedPeers() []peer.ID
	ListBlockedSubnets() []*net.IPNet
	UnblockAddr(ip net.IP) error
	UnblockPeer(p peer.ID) error
	UnblockSubnet(ipnet *net.IPNet) error

	// Sets the ID for the node running the peer manager
	SetSelfID(p2p.PeerID)
	GetSelfID() p2p.PeerID

	// Sets the DHT provided from the Host interface
	SetDHT(*dual.DHT)

	// Sets the streamManager interface
	SetStreamManager(streamManager.StreamManager)

	// Announces to the DHT that we are providing this data
	Provide(context.Context, common.Location, interface{}) error

	// Removes a peer from all the quality buckets
	RemovePeer(p2p.PeerID) error

	// Returns c_peerCount peers starting at the requested quality level of peers
	// If there are not enough peers at the requested quality, it will return lower quality peers
	// If there still aren't enough peers, it will query the DHT for more
	GetPeers(topic *pubsubManager.Topic, quality PeerQuality) map[p2p.PeerID]struct{}

	// Increases the peer's liveliness score
	MarkLivelyPeer(peerID p2p.PeerID, topic *pubsubManager.Topic)
	// Decreases the peer's liveliness score
	MarkLatentPeer(peerID p2p.PeerID, topic *pubsubManager.Topic)

	// Increases the peer's liveliness score. Not exposed outside of NetworkingAPI
	MarkResponsivePeer(peerID p2p.PeerID, topic *pubsubManager.Topic)
	// Decreases the peer's liveliness score. Not exposed outside of NetworkingAPI
	MarkUnresponsivePeer(peerID p2p.PeerID, topic *pubsubManager.Topic)

	// Protects the peer's connection from being disconnected
	ProtectPeer(p2p.PeerID)
	// Remove protection from the peer's connection
	UnprotectPeer(p2p.PeerID)
	// Bans the peer's connection from being re-established
	BanPeer(p2p.PeerID)

	// Stops the peer manager
	Stop() error
}

PeerManager is an interface that extends libp2p Connection Manager and Gater

func NewManager

func NewManager(ctx context.Context, low int, high int, datastore datastore.Datastore) (PeerManager, error)

type PeerQuality

type PeerQuality int
const (
	Best PeerQuality = iota
	Responsive
	LastResort
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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