peerManager

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

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) AdjustPeerQuality added in v0.32.0

func (pm *BasicPeerManager) AdjustPeerQuality(peer p2p.PeerID, topic string, adjFn func(int) int)

func (*BasicPeerManager) BanPeer

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

func (*BasicPeerManager) CloseStream

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

func (*BasicPeerManager) GetHost

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

func (*BasicPeerManager) GetPeerQuality added in v0.40.1

func (pm *BasicPeerManager) GetPeerQuality(peer p2p.PeerID) int

func (*BasicPeerManager) GetPeers

func (pm *BasicPeerManager) GetPeers(topic *pubsubManager.Topic) 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) GetStreamPeers added in v0.40.1

func (pm *BasicPeerManager) GetStreamPeers() []peer.ID

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) RefreshBootpeers added in v0.30.0

func (pm *BasicPeerManager) RefreshBootpeers() []peer.AddrInfo

func (*BasicPeerManager) RemovePeer

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

func (*BasicPeerManager) SetDHT

func (pm *BasicPeerManager) SetDHT(dht *kaddht.IpfsDHT)

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, protoversion libp2pprotocol.ID, reporter libp2pmetrics.Reporter) 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(*kaddht.IpfsDHT)

	// 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

	// GetPeers gets randomized set of peers from the database based on the
	// request degree of the topic
	GetPeers(topic *pubsubManager.Topic) map[p2p.PeerID]struct{}

	// RefreshBootpeers returns all the current bootpeers for bootstrapping
	RefreshBootpeers() []peer.AddrInfo

	// Adjust the quality score of a peer by applying the given adjustment function
	AdjustPeerQuality(p2p.PeerID, string, func(int) int)

	// 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
	All
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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