wantmanager

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerHandler

type PeerHandler interface {
	// Connected is called when a peer connects, with any initial want-haves
	// that have been broadcast to all peers (as part of session discovery)
	Connected(p peer.ID, initialWants []cid.Cid)
	// Disconnected is called when a peer disconnects
	Disconnected(p peer.ID)
	// BroadcastWantHaves sends want-haves to all connected peers
	BroadcastWantHaves(ctx context.Context, wantHaves []cid.Cid)
	// SendCancels sends cancels to all peers that had previously been sent
	// a want-block or want-have for the given key
	SendCancels(context.Context, []cid.Cid)
}

PeerHandler sends wants / cancels to other peers

type SessionManager

type SessionManager interface {
	ReceiveFrom(p peer.ID, blks []cid.Cid, haves []cid.Cid, dontHaves []cid.Cid) []sessionmanager.Session
}

SessionManager receives incoming messages and distributes them to sessions

type WantManager

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

WantManager

  • informs the SessionManager and BlockPresenceManager of incoming information and cancelled sessions
  • informs the PeerManager of connects and disconnects
  • manages the list of want-haves that are broadcast to the internet (as opposed to being sent to specific peers)

func New

New initializes a new WantManager for a given context.

func (*WantManager) BroadcastWantHaves

func (wm *WantManager) BroadcastWantHaves(ctx context.Context, ses uint64, wantHaves []cid.Cid)

BroadcastWantHaves is called when want-haves should be broadcast to all connected peers (as part of session discovery)

func (*WantManager) Connected

func (wm *WantManager) Connected(p peer.ID)

Connected is called when a new peer connects

func (*WantManager) Disconnected

func (wm *WantManager) Disconnected(p peer.ID)

Disconnected is called when a peer disconnects

func (*WantManager) ReceiveFrom

func (wm *WantManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid.Cid, haves []cid.Cid, dontHaves []cid.Cid)

ReceiveFrom is called when a new message is received

func (*WantManager) RemoveSession

func (wm *WantManager) RemoveSession(ctx context.Context, ses uint64)

RemoveSession is called when the session is shut down

func (*WantManager) SetSessionManager

func (wm *WantManager) SetSessionManager(sm SessionManager)

Jump to

Keyboard shortcuts

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