p2p

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MPL-2.0 Imports: 29 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DesiredRelays  = 2
	RelayBootDelay = 20 * time.Second

	DHTProtocolPrefix protocol.ID = "/awl"
)

Variables

This section is empty.

Functions

func DefaultListenAddrs

func DefaultListenAddrs() []multiaddr.Multiaddr

func UnicastListenAddrs

func UnicastListenAddrs() []multiaddr.Multiaddr

Types

type BootstrapPeerDebugInfo

type BootstrapPeerDebugInfo struct {
	Error       string   `json:",omitempty"`
	Connections []string `json:",omitempty"`
}

type ConnectionInfo

type ConnectionInfo struct {
	Multiaddr    string
	ThroughRelay bool
	RelayPeerID  string
	Address      string
	Protocol     string
	Direction    string
	Opened       time.Time
	Transient    bool
}

type HostConfig

type HostConfig struct {
	PrivKeyBytes   []byte
	ListenAddrs    []multiaddr.Multiaddr
	UserAgent      string
	BootstrapPeers []peer.AddrInfo

	Libp2pOpts  []libp2p.Option
	ConnManager struct {
		LowWater    int
		HighWater   int
		GracePeriod time.Duration
	}
	Peerstore    peerstore.Peerstore
	DHTDatastore ds.Batching
	DHTOpts      []dht.Option
}

type IDService

type IDService interface {
	Close() error
	OwnObservedAddrs() []multiaddr.Multiaddr
	ObservedAddrsFor(local multiaddr.Multiaddr) []multiaddr.Multiaddr
	IdentifyConn(c network.Conn)
	IdentifyWait(c network.Conn) <-chan struct{}
}

type P2p

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

func NewP2p

func NewP2p(ctx context.Context) *P2p

func (*P2p) AnnouncedAs

func (p *P2p) AnnouncedAs() []multiaddr.Multiaddr

func (*P2p) Bootstrap

func (p *P2p) Bootstrap() error

func (*P2p) BootstrapPeersStats

func (p *P2p) BootstrapPeersStats() (int, int)

BootstrapPeersStats returns total peers count and connected count.

func (*P2p) BootstrapPeersStatsDetailed

func (p *P2p) BootstrapPeersStatsDetailed() map[string]BootstrapPeerDebugInfo

func (*P2p) ClearBackoff

func (p *P2p) ClearBackoff(peerID peer.ID)

func (*P2p) Close

func (p *P2p) Close() error

func (*P2p) ConnectPeer

func (p *P2p) ConnectPeer(ctx context.Context, peerID peer.ID) error

func (*P2p) ConnectedPeersCount

func (p *P2p) ConnectedPeersCount() int

func (*P2p) ConnectionsLastTrimAgo

func (p *P2p) ConnectionsLastTrimAgo() time.Duration

func (*P2p) FindPeer

func (p *P2p) FindPeer(ctx context.Context, id peer.ID) (peer.AddrInfo, error)

func (*P2p) Host

func (p *P2p) Host() host.Host

func (*P2p) IDService

func (p *P2p) IDService() IDService

func (*P2p) InitHost

func (p *P2p) InitHost(hostConfig HostConfig) (host.Host, error)

func (*P2p) IsConnected

func (p *P2p) IsConnected(peerID peer.ID) bool

func (*P2p) MaintainBackgroundConnections

func (p *P2p) MaintainBackgroundConnections(ctx context.Context, interval time.Duration, knownPeersIdsFunc func() []peer.ID)

func (*P2p) NetworkSize added in v0.8.0

func (p *P2p) NetworkSize() (int32, error)

func (*P2p) NetworkStats

func (p *P2p) NetworkStats() metrics.Stats

func (*P2p) NetworkStatsByPeer

func (p *P2p) NetworkStatsByPeer() map[peer.ID]metrics.Stats

func (*P2p) NetworkStatsByProtocol

func (p *P2p) NetworkStatsByProtocol() map[protocol.ID]metrics.Stats

func (*P2p) NetworkStatsForPeer

func (p *P2p) NetworkStatsForPeer(peerID peer.ID) metrics.Stats

func (*P2p) NewStream

func (p *P2p) NewStream(ctx context.Context, id peer.ID, proto protocol.ID) (network.Stream, error)

func (*P2p) OpenConnectionsCount

func (p *P2p) OpenConnectionsCount() int

func (*P2p) OpenStreamStats

func (p *P2p) OpenStreamStats() map[protocol.ID]map[string]int

func (*P2p) OpenStreamsCount

func (p *P2p) OpenStreamsCount() int64

func (*P2p) OwnObservedAddrs

func (p *P2p) OwnObservedAddrs() []multiaddr.Multiaddr

func (*P2p) PeerConnectionsInfo

func (p *P2p) PeerConnectionsInfo(peerID peer.ID) []ConnectionInfo

func (*P2p) PeerID

func (p *P2p) PeerID() peer.ID

func (*P2p) PeerUserAgent

func (p *P2p) PeerUserAgent(peerID peer.ID) string

func (*P2p) PeersWithAddrsCount

func (p *P2p) PeersWithAddrsCount() int

func (*P2p) ProtectPeer

func (p *P2p) ProtectPeer(id peer.ID)

func (*P2p) Reachability

func (p *P2p) Reachability() network.Reachability

func (*P2p) RoutingTablePeers

func (p *P2p) RoutingTablePeers() []kbucket.PeerInfo

func (*P2p) RoutingTableSize

func (p *P2p) RoutingTableSize() int

func (*P2p) SubscribeConnectionEvents

func (p *P2p) SubscribeConnectionEvents(onConnected, onDisconnected func(network.Network, network.Conn))

func (*P2p) UnprotectPeer

func (p *P2p) UnprotectPeer(id peer.ID)

func (*P2p) Uptime

func (p *P2p) Uptime() time.Duration

Jump to

Keyboard shortcuts

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