peer_manager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downstream

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

Downstream holds the downstream peers that are behind the proxy

func (*Downstream) Contains

func (d *Downstream) Contains(addr ma.Multiaddr) bool

Contains returns true if the given multiaddr is one of the downstream peers

func (*Downstream) ContainsPeer

func (d *Downstream) ContainsPeer(id peer.ID) bool

ContainsPeer returns true if the given peer ID is one of the downstream peers

func (*Downstream) Current

func (d *Downstream) Current() peer.ID

Current returns the current downstream peer in the list

func (*Downstream) Next

func (d *Downstream) Next() peer.ID

Next gets the next peer to connect to. At the moment it does round-robin

func (*Downstream) PeerAddrs

func (d *Downstream) PeerAddrs() []ma.Multiaddr

PeerAddrs returns a slice containing all the downstream peer bitswap multiaddrs

func (*Downstream) Peers

func (d *Downstream) Peers() []peer.ID

Peers returns a slice containing all the downstream peer IDs

func (*Downstream) String

func (d *Downstream) String() string

String gives a string representation of all the peers

type IdResponse

type IdResponse struct {
	ID        string
	Addresses []string
}

type Notifiee

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

func (*Notifiee) ClosedStream

func (n *Notifiee) ClosedStream(net network.Network, s network.Stream)

func (*Notifiee) Connected

func (n *Notifiee) Connected(net network.Network, conn network.Conn)

func (*Notifiee) Disconnected

func (n *Notifiee) Disconnected(net network.Network, conn network.Conn)

func (*Notifiee) Listen

func (n *Notifiee) Listen(net network.Network, addr ma.Multiaddr)

func (*Notifiee) ListenClose

func (n *Notifiee) ListenClose(net network.Network, addr ma.Multiaddr)

func (*Notifiee) OpenedStream

func (n *Notifiee) OpenedStream(net network.Network, s network.Stream)

type PeerInfo

type PeerInfo struct {
	ID       peer.ID
	Addr     ma.Multiaddr // Bitswap address
	IP       string       // Or hostname
	HttpPort uint16
}

func (*PeerInfo) String

func (pi *PeerInfo) String() string

type PeerManager

type PeerManager struct {
	UpWants   *WantMap // Wants by upstream peers
	DownWants *WantMap // Wants by downstream peers (in response to /api/v0/refs from upstream)
	SentWants *WantMap // All wants that have been sent, and the peer that they were sent to
	// contains filtered or unexported fields
}

func New

func New(host host.Host, ctx context.Context, addrs ...ma.Multiaddr) (*PeerManager, error)

func (*PeerManager) AddRefCid

func (pm *PeerManager) AddRefCid(ip net.IP, c cid.Cid)

AddRef adds an IP <-> CID mapping

func (*PeerManager) AddUpstreamPeerIP

func (pm *PeerManager) AddUpstreamPeerIP(addr ma.Multiaddr) error

AddUpstreamPeerIP adds a mapping between an upstream peer ID and its IP address

func (*PeerManager) CidsForRefIp

func (pm *PeerManager) CidsForRefIp(ip net.IP) []cid.Cid

CidsForRefIp returns all the CIDs that have been requested by the IP via /api/v0/refs

func (*PeerManager) ConnectAllDown

func (pm *PeerManager) ConnectAllDown()

ConnectAllDown connects to all downstream peers

func (*PeerManager) CurrentDownPeer

func (pm *PeerManager) CurrentDownPeer() peer.ID

CurrentDownPeer returns the last-selected downstream peer

func (*PeerManager) DeleteRefCid

func (pm *PeerManager) DeleteRefCid(ip net.IP, c cid.Cid)

DeleteRefCid removes an IP <-> CID mapping

func (*PeerManager) DeleteUpstreamPeerIP

func (pm *PeerManager) DeleteUpstreamPeerIP(id peer.ID)

DeleteUpstreamPeerIP deletes one peerID <-> IP address association

func (*PeerManager) DownPeerInfo

func (pm *PeerManager) DownPeerInfo(id peer.ID) (PeerInfo, bool)

DownPeerInfo returns the info of a downstream peer

func (*PeerManager) DownPeers

func (pm *PeerManager) DownPeers() []ma.Multiaddr

DownPeers returns the multiaddrs of all downstream peers

func (*PeerManager) DownstreamForPeer

func (pm *PeerManager) DownstreamForPeer(upPeer peer.ID) []peer.ID

DownstreamForPeer returns the downstream peer associated with an upstream peer. It returns a one-element array for symmetry with UpstreamForPeer.

func (*PeerManager) IpFromMultiaddr

func (pm *PeerManager) IpFromMultiaddr(addr ma.Multiaddr) (net.IP, error)

IpFromMultiaddr extracts the IP address from a multiaddr

func (*PeerManager) IsDownstream

func (pm *PeerManager) IsDownstream(id peer.ID) bool

IsDownstream returns true if a peer is a downstream peer

func (*PeerManager) RefsForCid

func (pm *PeerManager) RefsForCid(c cid.Cid) []net.IP

RefsForCid returns all the IPs that have requested the CID via /api/v0/refs

func (*PeerManager) UpPeers

func (pm *PeerManager) UpPeers() []peer.ID

UpPeers returns the peer IDs of all connected upstream peers

func (*PeerManager) UpstreamForPeer

func (pm *PeerManager) UpstreamForPeer(id peer.ID) []peer.ID

UpstreamForPeer returns all the upstream peers associated with a downstream peer

func (*PeerManager) UpstreamIPForPeer

func (pm *PeerManager) UpstreamIPForPeer(id peer.ID) (net.IP, bool)

UpstreamIPForPeer returns the upstream IP associated with a given peer.

func (*PeerManager) UpstreamPeersForIP

func (pm *PeerManager) UpstreamPeersForIP(ip net.IP) []peer.ID

UpstreamPeersForIP returns the upstream peers associated with a given IP. Note that there can be several in the case of peers behind a NAT.

type WantMap

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

WantMap is a wrapper around a peerId <-> CID BiMultiMap

func NewWantMap

func NewWantMap() *WantMap

func (*WantMap) Add

func (wm *WantMap) Add(p peer.ID, c cid.Cid)

func (*WantMap) AllCids

func (wm *WantMap) AllCids() []cid.Cid

func (*WantMap) AllPeers

func (wm *WantMap) AllPeers() []peer.ID

func (*WantMap) CidsForPeer

func (wm *WantMap) CidsForPeer(id peer.ID) []cid.Cid

func (*WantMap) Clear

func (wm *WantMap) Clear()

func (*WantMap) Delete

func (wm *WantMap) Delete(p peer.ID, c cid.Cid)

func (*WantMap) DeleteCid

func (wm *WantMap) DeleteCid(c cid.Cid)

func (*WantMap) DeletePeer

func (wm *WantMap) DeletePeer(p peer.ID)

func (*WantMap) Merge

func (wm *WantMap) Merge(other *WantMap) *WantMap

func (*WantMap) PeersForCid

func (wm *WantMap) PeersForCid(c cid.Cid) []peer.ID

Jump to

Keyboard shortcuts

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