net

package
v1.10.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0, MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const (
	GossipScoreThreshold             = -500
	PublishScoreThreshold            = -1000
	GraylistScoreThreshold           = -2500
	AcceptPXScoreThreshold           = 1000
	OpportunisticGraftScoreThreshold = 3.5
)

Variables

This section is empty.

Functions

func FilecoinDHT

func FilecoinDHT(network string) protocol.ID

FilecoinDHT is creates a protocol for the filecoin DHT.

func NewGossipSub added in v1.8.0

func NewGossipSub(ctx context.Context,
	h host.Host,
	sk *ScoreKeeper,
	networkName string,
	drandSchedule map[abi.ChainEpoch]config.DrandEnum,
	bootNodes []peer.AddrInfo,
) (*pubsub.PubSub, error)

func ParseAddresses

func ParseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error)

ParseAddresses is a function that takes in a slice of string peer addresses (multiaddr + peerid) and returns a slice of properly constructed peers

Types

type Network

type Network struct {
	metrics.Reporter
	*Router
	// contains filtered or unexported fields
}

Network is a unified interface for dealing with libp2p

func New

func New(
	host host.Host,
	rawHost types.RawHost,
	router *Router,
	reporter metrics.Reporter,
) *Network

New returns a new Network

func (*Network) AgentVersion added in v1.6.1

func (network *Network) AgentVersion(ctx context.Context, p peer.ID) (string, error)

AgentVersion returns agent version for a given peer id

func (*Network) AutoNatStatus added in v1.6.1

func (network *Network) AutoNatStatus() (types.NatInfo, error)

AutoNatStatus return a struct with current NAT status and public dial address

func (*Network) Connect

func (network *Network) Connect(ctx context.Context, p peer.AddrInfo) error

Connect connects to peer at the given address. Does not retry.

func (*Network) Connectedness added in v1.6.1

func (network *Network) Connectedness(p peer.ID) (network2.Connectedness, error)

Connectedness returns a state signaling connection capabilities

func (*Network) Disconnect added in v1.6.1

func (network *Network) Disconnect(p peer.ID) error

Disconnect disconnect to peer at the given address

func (*Network) GetBandwidthStats

func (network *Network) GetBandwidthStats() metrics.Stats

GetBandwidthStats gets stats on the current bandwidth usage of the network

func (*Network) GetBandwidthStatsByPeer added in v1.6.1

func (network *Network) GetBandwidthStatsByPeer() (map[string]metrics.Stats, error)

GetBandwidthStatsByPeer returns statistics about the nodes bandwidth usage and current rate per peer

func (*Network) GetBandwidthStatsByProtocol added in v1.6.1

func (network *Network) GetBandwidthStatsByProtocol() (map[protocol.ID]metrics.Stats, error)

GetBandwidthStatsByProtocol returns statistics about the nodes bandwidth usage and current rate per protocol

func (*Network) GetPeerAddresses

func (network *Network) GetPeerAddresses() []ma.Multiaddr

GetPeerAddresses gets the current addresses of the node

func (*Network) GetPeerID

func (network *Network) GetPeerID() peer.ID

GetPeerID gets the current peer id from libp2p-host

func (*Network) PeerInfo added in v1.6.1

func (network *Network) PeerInfo(ctx context.Context, p peer.ID) (*types.ExtendedPeerInfo, error)

PeerInfo searches the peer info for a given peer id

func (*Network) Peers

func (network *Network) Peers(ctx context.Context) ([]peer.AddrInfo, error)

Peers lists peers currently available on the network

func (*Network) ProtectAdd added in v1.6.1

func (network *Network) ProtectAdd(peers []peer.ID) error

ProtectAdd protect peer at the given peers id

func (*Network) ProtectList added in v1.6.1

func (network *Network) ProtectList() ([]peer.ID, error)

ProtectList returns the peers that are protected

func (*Network) ProtectRemove added in v1.6.1

func (network *Network) ProtectRemove(peers []peer.ID) error

ProtectRemove unprotect peer at the given peers id

type Router

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

Router exposes the methods on the internal filecoin router that are needed by the system plumbing API.

func NewRouter

func NewRouter(r routing.Routing) *Router

NewRouter builds a new router.

func (*Router) FindPeer

func (r *Router) FindPeer(ctx context.Context, peerID peer.ID) (peer.AddrInfo, error)

FindPeer searches the libp2p router for a given peer id

func (*Router) FindProvidersAsync

func (r *Router) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo

FindProvidersAsync searches for and returns peers who are able to provide a given key.

func (*Router) GetClosestPeers

func (r *Router) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error)

GetClosestPeers returns a channel of the K closest peers to the given key, K is the 'K Bucket' parameter of the Kademlia DHT protocol.

type ScoreKeeper added in v1.8.0

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

func NewScoreKeeper added in v1.8.0

func NewScoreKeeper() *ScoreKeeper

func (*ScoreKeeper) Get added in v1.8.0

func (sk *ScoreKeeper) Get() map[peer.ID]*pubsub.PeerScoreSnapshot

func (*ScoreKeeper) Update added in v1.8.0

func (sk *ScoreKeeper) Update(scores map[peer.ID]*pubsub.PeerScoreSnapshot)

Directories

Path Synopsis
Package exchange contains the ChainExchange server and client components.
Package exchange contains the ChainExchange server and client components.

Jump to

Keyboard shortcuts

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